コード例 #1
0
        public BuildingBackOfficeModel AddBlankAddress(BuildingBackOfficeModel model)
        {
            Address blankAddress = new Address();

            blankAddress.Id             = 0;
            blankAddress.BuildingId     = model.Building == null ? 0 : model.Building.Id;
            blankAddress.Address1       = string.Empty;
            blankAddress.Address2       = string.Empty;
            blankAddress.City           = string.Empty;
            blankAddress.State_Province = string.Empty;
            blankAddress.Country        = string.Empty;
            blankAddress.ZipCode        = string.Empty;

            if (model.Addresses != null)
            {
                model.Addresses.Add(blankAddress);
            }
            else
            {
                List <Address> addresses = new List <Address>();
                addresses.Add(blankAddress);
                model.Addresses = addresses;
            }

            return(model);
        }
コード例 #2
0
        public BuildingBackOfficeModel GetById(int id)
        {
            BuildingBackOfficeModel model = new BuildingBackOfficeModel();
            var            building       = _bldgRepo.GetById(id);
            AddressManager addressMgr     = new AddressManager();

            model.Building  = building;
            model.Addresses = addressMgr.GetByBuildingId(building.Id);
            return(model);
        }
コード例 #3
0
        public BuildingBackOfficeModel PostSave(BuildingBackOfficeModel model)
        {
            var building  = model.Building;
            var addresses = model.Addresses;

            umbraco.BusinessLogic.User siteAdmin = umbraco.helper.GetCurrentUmbracoUser();

            if (building.Id > 0)
            {
                building.ModifiedBy = siteAdmin.Id;
                building.ModifiedOn = DateTime.Now;
                _bldgRepo.Update(building.Id, building);
            }
            else
            {
                building.CreatedBy  = siteAdmin.Id;
                building.CreatedOn  = DateTime.Now;
                building.ModifiedBy = siteAdmin.Id; //should be nullable BM-21 fix
                building.ModifiedOn = DateTime.Now; //should be nullable BM-21 fix
                var buildingInserted = _bldgRepo.Insert(building);
                building.Id = buildingInserted.Id;
            }

            foreach (var address in addresses)
            {
                if (address.Id > 0)
                {
                    //DatabaseContext.Database.Update(address);
                    _addressRepo.Update(address.Id, address);
                }
                else
                {
                    if (!IsCanceledAddress(address))
                    {
                        address.BuildingId = building.Id;
                        //DatabaseContext.Database.Save(address);
                        _addressRepo.Insert(address);
                    }
                }
            }

            return(model);
        }