public Group UpdateGroup(Group model, Guid recordId) { gnl_user_groups group = new gnl_user_groups(); group = this.GetUserGroups(recordId); group.group_name = model.group_name; group.group_explanation = model.group_explanation; if (string.IsNullOrEmpty(model.ManagerName)) { group.manager_id = null; } else { if (!string.IsNullOrEmpty(model.ManagerId) && GlobalHelper.IsGuid(model.ManagerId)) { group.manager_id = Guid.Parse(model.ManagerId); } } group.is_active = model.is_active; group.updated_at = DateTime.UtcNow; group.updated_by = SessionContext.Current.ActiveUser.UserUid; this.Kaydet(); return(model); }
public Group DeleteGroup(Group model, Guid recordId) { gnl_user_groups group = new gnl_user_groups(); group = this.GetUserGroups(recordId); group.is_deleted = true; group.is_active = false; group.deleted_at = DateTime.UtcNow; group.deleted_by = SessionContext.Current.ActiveUser.UserUid; this.Kaydet(); return(model); }
public Group BindGroup(Group model, Guid recordId) { gnl_user_groups group = new gnl_user_groups(); group = this.GetUserGroups(recordId); model.group_name = group.group_name; model.group_explanation = group.group_explanation; model.is_active = group.is_active.Value; if (group.manager_id != null) { model.ManagerId = group.manager_id.ToString(); } return(model); }
public void AddGroup(gnl_user_groups group, Group model) { group.group_id = Guid.NewGuid(); group.group_name = model.group_name; group.group_explanation = model.group_explanation; group.is_active = model.is_active; if (string.IsNullOrEmpty(model.ManagerName)) { group.manager_id = null; } else { if (!string.IsNullOrEmpty(model.ManagerId) && GlobalHelper.IsGuid(model.ManagerId)) { group.manager_id = Guid.Parse(model.ManagerId); } } group.is_deleted = false; db.gnl_user_groups.Add(group); this.Kaydet(); }
public ActionResult Group(Group model) { Guid recordId = Guid.Empty; GenelRepository gnlDB = RepositoryManager.GetRepository <GenelRepository>(); SessionContext.Current.ActiveUser.MenuId = model.MenuId; ViewBag.Success = true; ModelState.Remove("is_active"); if (model.FromDeleteButton == "1") { if (GlobalHelper.IsGuid(model.RecordId)) { gnlDB.DeleteGroup(model, Guid.Parse(model.RecordId)); return(RedirectToAction("ListPage", "General", new { MenuId = Dcm.Source.GlobalHelper.Encrypt(model.MenuId) })); } } else { if (ModelState.IsValid) { if (GlobalHelper.IsGuid(model.RecordId)) { recordId = Guid.Parse(model.RecordId); try { model = gnlDB.UpdateGroup(model, recordId); ViewBag.ResultMessage = Resources.GlobalResource.transaction_success; } catch (Exception exp) { ViewBag.Success = false; ModelState.AddModelError("Error", exp.Message); } } else { try { gnl_user_groups group = new gnl_user_groups(); gnlDB.AddGroup(group, model); model.RecordId = group.group_id.ToString(); ViewBag.ResultMessage = Resources.GlobalResource.transaction_success; } catch (Exception exp) { ViewBag.Success = false; ModelState.AddModelError("Error", exp.Message); } } } else { ViewBag.Success = false; } if (string.IsNullOrEmpty(model.ManagerName)) { model.ManagerId = null; } if (!string.IsNullOrEmpty(model.ManagerId) && GlobalHelper.IsGuid(model.ManagerId)) { gnl_users userManager = gnlDB.GetUser(Guid.Parse(model.ManagerId)); if (userManager != null) { model.ManagerName = userManager.name + " " + userManager.surname; } } } return(View(model)); }