Exemplo n.º 1
0
        public ActionResult BUCreate(BusinessUnitEditorModel model)
        {
            if (model != null)
            {
                //Build in duplicate check (Department Name)
                var department = new BusinessUnit()
                {
                    Name = model.Name
                };
                context.BusinessUnit.Add(department);

                var BUid = context.BusinessUnit.Where(x => x.Name == model.Name).Select(x => x.BusinessUnitId).FirstOrDefault();

                var access = new BusinessUnitAccess()
                {
                    BusinessUnitId = BUid, RoleId = model.RoleId
                };
                context.BusinessUnitAccess.Add(access);

                var managers = new BusinessUnitManagement()
                {
                    BusinessUnitId = BUid, TeamLeader = model.TeamLeader, GeneralManager = model.GeneralManager, HOD = model.HOD
                };                                                                                                                                                            //
                context.BusinessUnitManagement.Add(managers);

                context.SaveChanges();
                return(View(ViewBag.message("Successfully Submitted Department :" + model.Name)));

                //If duplicate send duplicate message back
            }
            else
            {
                return(View(ViewBag.message("Unable to submit department, please review and ensure all data is filled in.")));
            }
        }
        public ActionResult Departments()
        {
            var model = new BusinessUnitEditorModel()
            {
                RoleItems = GetRoleList()
            };

            return(View(model));
        }