Taylohtio/GeneralApi/GeneralApi.MOSS/CONTROLTEMPLATES/Taloyhtio/Integration/CondoInfo.ascx.cs

64 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using GeneralApi.Core.Repositories;
using Microsoft.Practices.ServiceLocation;
using Microsoft.SharePoint;
using Taloyhtio.GeneralApi.Common.Extensions;
using Taloyhtio.GeneralApi.MOSS.CONTROLTEMPLATES.Taloyhtio.Integration.App_LocalResources;
namespace Taloyhtio.GeneralApi.MOSS
{
public partial class CondoInfo : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.pnlEmpty.Visible = false;
this.pnlExists.Visible = false;
var condoRepository = ServiceLocator.Current.GetInstance<ICondoRepository>();
var condo = condoRepository.GetFirstByWebId(SPContext.Current.Web.ID);
if (condo == null || condo.Deactivated)
{
this.pnlEmpty.Visible = true;
return;
}
lblBusinessId.Text = this.stringOrEmpty(condo.BusinessId);
lblOfficialName.Text = this.stringOrEmpty(condo.OfficialName);
lblAddress.Text = this.stringOrEmpty(condo.Address);
lblPostcode.Text = this.stringOrEmpty(condo.Postcode);
lblTown.Text = this.stringOrEmpty(condo.Town);
this.lblBuildingsType.Text = this.stringOrEmpty(condo.BuildingsType);
this.lblBuildingsNumber.Text = this.intOrEmpty(condo.BuildingsNumber);
this.lblStaircasesNumber.Text = this.intOrEmpty(condo.StaircasesNumber);
this.lblBuildingYear.Text = this.intOrEmpty(condo.BuildingYear);
this.pnlExists.Visible = true;
}
}
private string stringOrEmpty(string str)
{
return (string.IsNullOrEmpty(str) ? this.getEmpty() : str);
}
private string getEmpty()
{
//return string.Format("<span style=\"color: gray\">{0}</span>", CondoInfo_ascx.Empty);
return string.Empty;
}
private string intOrEmpty(int? i)
{
return (i.HasValue ? i.Value.ToString() : this.getEmpty());
}
}
}