public ActionResult WorkgroupRoleDelete(WorkgroupRoleOperation op, Guid entityId) { WorkgroupRoleListModel model = new WorkgroupRoleListModel(); OperationResult result; if (op == WorkgroupRoleOperation.Role) { var roleBO = BusinessLogic.Core.GetFactory().GetInstance <IRoleBO>(); RoleDataContract role = roleBO.GetById(entityId); result = roleBO.Delete(role); } else { var wgBO = BusinessLogic.Core.GetFactory().GetInstance <IWorkgroupBO>(); WorkgroupDataContract wg = wgBO.GetById(entityId); result = wgBO.Delete(wg); } if (result.Status == OperationResultStatus.Succesfull) { return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration", model)); } else { model.Message = result.Message; } return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration", model)); }
public ActionResult AddRole(WorkgroupRoleListModel model) { if (model == null) { throw new ArgumentNullException("model"); } var roleBO = BusinessLogic.Core.GetFactory().GetInstance <IRoleBO>(); RoleDataContract role; bool update = model.RoleId != null && model.RoleId != Guid.Empty; if (!update) { role = new RoleDataContract(); role.Id = Guid.NewGuid(); } else { role = roleBO.GetById(model.RoleId); } role.Name = model.RoleDescription; if (string.IsNullOrEmpty(role.Name)) { model.Message = "Campo Descrição do Cargo é obrigatório."; return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration", model)); } OperationResult result; if (update) { result = roleBO.Update(role); } else { result = roleBO.Add(role); } if (result.Status == OperationResultStatus.ValidationFailure) { model.Message = result.Message; } else if (result.Status == OperationResultStatus.UnexpectedError) { model.Message = result.Exception.ToString(); } else { return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration")); } return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration", model)); }
public ActionResult AddWorkgroup(WorkgroupRoleListModel model) { if (model == null) { throw new ArgumentNullException("model"); } var wgBO = BusinessLogic.Core.GetFactory().GetInstance <IWorkgroupBO>(); WorkgroupDataContract wg; bool update = model.WorkgroupId != null && model.WorkgroupId != Guid.Empty; if (!update) { wg = new WorkgroupDataContract(); wg.Id = Guid.NewGuid(); } else { wg = wgBO.GetById(model.WorkgroupId); } wg.Name = model.WorkgroupDescription; wg.ParentWorkgroupId = model.ParentWorkgroupId; if (string.IsNullOrEmpty(wg.Name)) { model.Message = "Campo Descrição do Grupo é obrigatório."; return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration", model)); } OperationResult result; if (update) { result = wgBO.Update(wg); } else { result = wgBO.Add(wg); } if (result.Status == OperationResultStatus.ValidationFailure) { model.Message = result.Message; } else if (result.Status == OperationResultStatus.UnexpectedError) { model.Message = result.Exception.ToString(); } else { return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration")); } return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration", model)); }
public ActionResult WorkgroupRoleList(WorkgroupRoleListModel model) { var roleBO = BusinessLogic.Core.GetFactory().GetInstance <IRoleBO>(); var workgroupBO = BusinessLogic.Core.GetFactory().GetInstance <IWorkgroupBO>(); if (model == null) { model = new WorkgroupRoleListModel(); } else if (!string.IsNullOrEmpty(model.Message)) { ModelState.AddModelError("", model.Message); } model.Roles = roleBO.GetAll(); model.Workgroups = workgroupBO.GetAll(); return(View(model)); }
public ActionResult WorkgroupRoleEdit(WorkgroupRoleOperation op, Guid entityId) { WorkgroupRoleListModel model = new WorkgroupRoleListModel(); if (op == WorkgroupRoleOperation.Role) { var roleBO = BusinessLogic.Core.GetFactory().GetInstance <IRoleBO>(); RoleDataContract role = roleBO.GetById(entityId); model.RoleId = role.Id; model.RoleDescription = role.Name; } else if (op == WorkgroupRoleOperation.Workgroup) { var wgBO = BusinessLogic.Core.GetFactory().GetInstance <IWorkgroupBO>(); WorkgroupDataContract wg = wgBO.GetById(entityId); model.WorkgroupId = wg.Id; model.WorkgroupDescription = wg.Name; model.ParentWorkgroupId = wg.ParentWorkgroupId; } return(RedirectToAction("WorkgroupRoleList", "ResourceConfiguration", model)); }