コード例 #1
0
        public CompanyStructureViewModel returndivList()
        {
            CompanyStructureViewModel model = new CompanyStructureViewModel();
            var listData = _CompanyStructureMethod.getAllDivisionList();
            var listbiz  = _CompanyStructureMethod.getAllBusinessList();

            foreach (var item in listData)
            {
                var bizName = _CompanyStructureMethod.getBusinessListById(item.BusinessID);
                if (bizName != null)
                {
                    DivisionViewModel tableModel = new DivisionViewModel();
                    tableModel.Id           = item.Id;
                    tableModel.Name         = item.Name;
                    tableModel.BusinessName = bizName.Name;
                    tableModel.CreatedDate  = item.CreatedDate;
                    tableModel.Archived     = item.Archived;
                    model.divisionLists.Add(tableModel);
                }
            }
            foreach (var item in listbiz)
            {
                BusinessViewModel tableModel = new BusinessViewModel();
                tableModel.Id          = item.Id;
                tableModel.Name        = item.Name;
                tableModel.CreatedDate = item.CreatedDate;
                tableModel.Archived    = item.Archived;
                model.businessLists.Add(tableModel);
            }

            return(model);
        }
コード例 #2
0
        public CompanyStructureViewModel returndfunList()
        {
            CompanyStructureViewModel model = new CompanyStructureViewModel();
            var listfun  = _CompanyStructureMethod.getAllFunctionsList();
            var listData = _CompanyStructureMethod.getAllDivisionList();
            var listbiz  = _CompanyStructureMethod.getAllBusinessList();

            foreach (var item in listfun)
            {
                var bizsName = _CompanyStructureMethod.getBusinessListById((int)item.BusinessID);

                if (bizsName != null)
                {
                    var divName = _CompanyStructureMethod.getDivisionById(item.DivisionID);
                    if (divName != null)
                    {
                        FunctionViewModel tablepool = new FunctionViewModel();
                        tablepool.Id           = item.Id;
                        tablepool.Name         = item.Name;
                        tablepool.DivisionName = divName.Name;
                        tablepool.BusinessName = bizsName.Name;
                        tablepool.CreatedDate  = item.CreatedDate;
                        model.functionLists.Add(tablepool);
                    }
                    else
                    {
                        FunctionViewModel tablepool = new FunctionViewModel();
                        tablepool.Id           = item.Id;
                        tablepool.Name         = item.Name;
                        tablepool.DivisionName = "";
                        tablepool.BusinessName = bizsName.Name;
                        tablepool.CreatedDate  = item.CreatedDate;
                        model.functionLists.Add(tablepool);
                    }
                }
            }

            foreach (var item in listData)
            {
                DivisionViewModel tableModel = new DivisionViewModel();
                tableModel.Id          = item.Id;
                tableModel.Name        = item.Name;
                tableModel.BusinessID  = item.BusinessID;
                tableModel.CreatedDate = item.CreatedDate;
                tableModel.Archived    = item.Archived;
                model.divisionLists.Add(tableModel);
            }
            foreach (var item in listbiz)
            {
                BusinessViewModel tableModel = new BusinessViewModel();
                tableModel.Id          = item.Id;
                tableModel.Name        = item.Name;
                tableModel.CreatedDate = item.CreatedDate;
                tableModel.Archived    = item.Archived;
                model.businessLists.Add(tableModel);
            }

            return(model);
        }
コード例 #3
0
        public ActionResult GetFirstmodel()
        {
            int Id       = _hrUnitOfWork.Repository <CompanyStructure>().Where(a => a.CompanyId == CompanyId).Select(a => a.Id).FirstOrDefault();
            var compstru = new CompanyStructureViewModel();

            if (Id > 0)
            {
                compstru = _hrUnitOfWork.CompanyStructureRepository.GetStructure(Id, Language);
            }
            return(Json(compstru, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public ActionResult addBusinessList(string Name, int Id)
        {
            var data = _CompanyStructureMethod.SaveBusinessData(Name, Id, SessionProxy.UserId);

            if (!data)
            {
                return(Json("Error", JsonRequestBehavior.AllowGet));
            }
            else
            {
                CompanyStructureViewModel model = returnList();
                return(PartialView("_partialBusinessList", model));
            }
        }
コード例 #5
0
        public ActionResult deleteFunction(int Id)
        {
            var data = _CompanyStructureMethod.deleteFunction(Id, SessionProxy.UserId);

            if (!data)
            {
                return(Json("Error", JsonRequestBehavior.AllowGet));
            }
            else
            {
                CompanyStructureViewModel model = returndfunList();
                return(PartialView("_partialFunctionList", model));
            }
        }
コード例 #6
0
        public ActionResult GetModel(int?Id)
        {
            CompanyStructureViewModel compstru;

            if (Id != 0)
            {
                compstru = _hrUnitOfWork.CompanyStructureRepository.GetStructure(Id, Language);
            }
            else
            {
                compstru = new CompanyStructureViewModel();
            }
            return(Json(compstru, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public CompanyStructureViewModel returnList()
        {
            CompanyStructureViewModel model = new CompanyStructureViewModel();
            var listData = _CompanyStructureMethod.getAllBusinessList();

            foreach (var item in listData)
            {
                BusinessViewModel tableModel = new BusinessViewModel();
                tableModel.Id          = item.Id;
                tableModel.Name        = item.Name;
                tableModel.CreatedDate = item.CreatedDate;
                tableModel.Archived    = item.Archived;
                model.businessLists.Add(tableModel);
            }
            return(model);
        }
コード例 #8
0
        public ActionResult businessList()
        {
            CompanyStructureViewModel model = returnList();

            return(PartialView("_partialBusinessList", model));
        }
コード例 #9
0
        public ActionResult functionList()
        {
            CompanyStructureViewModel model = returndfunList();

            return(PartialView("_partialFunctionList", model));
        }
コード例 #10
0
        public ActionResult poolList()
        {
            CompanyStructureViewModel model = returndPoolList();

            return(PartialView("_partialPoolList", model));
        }
コード例 #11
0
        public ActionResult divisionList()
        {
            CompanyStructureViewModel model = returndivList();

            return(PartialView("_partialDivisionList", model));
        }
コード例 #12
0
        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));
        }