private void SetChildren(CompanyStructure model, List <CompanyStructure> depList) { var childs = depList.Where(x => x.ParentDepartmentId == model.Id).ToList(); if (childs.Count > 0) { foreach (var child in childs) { SetChildren(child, depList); model.ChildNodes.Add(child); } } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
public virtual IEnumerable <CompanyStructure> GetCompanyStructure(int companyId) { IEnumerable <CompanyStructure> result = CompanyStructure .Where(c => c.companyID == companyId) .Select(c => new CompanyStructure() { CompanyId = c.companyID, CompanyName = c.companyName, RegionId = c.regionID, RegionName = c.regionName, OfficeId = c.storeID, OfficeName = c.storeName, DepartmentId = c.departmentID, DepartmentName = c.departmentName, TenantId = c.TenantID, TenantName = c.TenantName }) .ToList(); return(result); }
public ActionResult Details(CompanyStructureViewModel model, OptionsViewModel moreInfo) { var Message = "OK"; List <Error> errors = new List <Error>(); if (ModelState.IsValid) { if (ServerValidationEnabled) { errors = _hrUnitOfWork.CompanyStructureRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "CompanyStructure", TableName = "CompanyStructures", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), ParentColumn = "CompanyId", Culture = Language }); if (errors.Count() > 0) { foreach (var e in errors) { foreach (var errorMsg in e.errors) { ModelState.AddModelError(errorMsg.field, errorMsg.message); } } return(Json(Models.Utils.ParseFormErrors(ModelState))); } } } else { return(Json(Models.Utils.ParseFormErrors(ModelState))); } CompanyStructure compStruc; if (model.Id == 0) // New { compStruc = new CompanyStructure(); _hrUnitOfWork.PositionRepository.AddLName(Language, compStruc.Name, model.Name, model.LocalName); AutoMapper(new Models.AutoMapperParm { Destination = compStruc, Source = model, ObjectName = "CompanyStructure", Options = moreInfo, Transtype = TransType.Insert }); compStruc.CompanyId = CompanyId; compStruc.CreatedTime = DateTime.Now; compStruc.CreatedUser = UserName; _hrUnitOfWork.CompanyStructureRepository.Add(compStruc); } else // Edit { compStruc = _hrUnitOfWork.Repository <CompanyStructure>().Where(a => a.Id == model.Id).FirstOrDefault(); _hrUnitOfWork.PositionRepository.AddLName(Language, compStruc.Name, model.Name, model.LocalName); AutoMapper(new Models.AutoMapperParm { Destination = compStruc, Source = model, ObjectName = "CompanyStructure", Version = 0, Options = moreInfo, Transtype = TransType.Update }); compStruc.ModifiedTime = DateTime.Now; compStruc.ModifiedUser = UserName; _hrUnitOfWork.CompanyStructureRepository.Attach(compStruc); _hrUnitOfWork.CompanyStructureRepository.Entry(compStruc).State = EntityState.Modified; } try { var err = SaveChanges(Language); if (err.Count() > 0) { foreach (var item in err) { Message = item.errors.Select(a => a.message).FirstOrDefault(); } return(Json(Message)); } } catch (Exception ex) { var msg = _hrUnitOfWork.HandleDbExceptions(ex, Language); if (msg.Length > 0) { return(Json(msg)); } } return(Json(Message)); }