public int EditBuilding(int id, int?Global, string host) { int result = 0; using (IUnitOfWork work = UnitOfWork.Begin()) { var building_object = _buildingObjectRepository.FindById(id); var old_global = building_object.GlobalBuilding; building_object.GlobalBuilding = Global; var flag = ""; // building_object.Comment = comment; work.Commit(); if (old_global != building_object.GlobalBuilding) { var message = new XElement(XMLLogLiterals.LOG_MESSAGE); message.Add(XMLLogMessageHelper.TemplateToXml("LogBuildingObjectGlobalChange", new List <string> { "Building ", building_object.BuildingId.ToString(), " from ", old_global.ToString(), " to ", Global.ToString() })); // message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageCommentChange", new List<string> { string.IsNullOrWhiteSpace(old_comment) ? " " : old_comment, string.IsNullOrWhiteSpace(comment) ? " " : comment })); _logService.CreateLog(CurrentUser.Get().Id, "web", flag, host, CurrentUser.Get().CompanyId, message.ToString()); } } return(result); }
public ActionResult Edit(int id) { var bevm = CreateViewModel <BuildingObjectEditViewModel>(); Mapper.Map(_buildingObjectRepository.FindById(id), bevm.BuildingObject); return(PartialView(bevm)); }
public int CreateCompany(int?parentId, string name, string comment, bool isCanUseOwnCards, string host, IEnumerable <CompanyBuildingDto> companyBuildings) { int result = 0; using (IUnitOfWork work = UnitOfWork.Begin()) { Company company = DomainObjectFactory.CreateCompany(); IFoxSecIdentity identity = CurrentUser.Get(); var message = new XElement(XMLLogLiterals.LOG_MESSAGE); message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageCompanyCreated", new List <string> { name, identity.LoginName })); if (parentId != null) { message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageCompanyParent", new List <string> { _companyRepository.FindById(parentId.Value).Name })); } message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageComment", new List <string> { comment })); company.Name = name; company.ModifiedLast = DateTime.Now; company.ModifiedBy = identity.LoginName; company.Comment = comment; company.Active = true; company.IsDeleted = false; company.ParentId = parentId; company.IsCanUseOwnCards = isCanUseOwnCards; message.Add(isCanUseOwnCards ? XMLLogMessageHelper.TemplateToXml("LogMessageCanUseOwnCardsTrue", null) : XMLLogMessageHelper.TemplateToXml("LogMessageCanUseOwnCardsFalse", null)); if (companyBuildings != null) { foreach (var companyBuildingDto in companyBuildings) { if (companyBuildingDto.IsSelected) { var cbo = DomainObjectFactory.CreateCompanyBuildingObject(); var bo = _buildingObjectRepository.FindById(companyBuildingDto.BuildingObjectId); message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageBuildingObjectAdded", new List <string> { bo.Description, bo.Building.Name })); cbo.BuildingObjectId = companyBuildingDto.BuildingObjectId; cbo.CompanyId = company.Id; cbo.ValidFrom = DateTime.Now; cbo.ValidTo = DateTime.Now.AddYears(50); cbo.IsDeleted = false; company.CompanyBuildingObjects.Add(cbo); } } } _companyRepository.Add(company); work.Commit(); result = company.Id; _logservice.CreateLog(CurrentUser.Get().Id, "web", flag, host, CurrentUser.Get().CompanyId, message.ToString()); } return(result); }