public UIIssueClass_List(IssueClass model) { this.id = model.id; this.name = model.name; this.editcmdlink = Images.EDIT(); this.deletecmdlink = Images.DELETE(); }
private static IssueClass GetDBEntity(DataContext context, int id) { IssueClass dbentity = context.IssueClasses.Find(id); if (dbentity == null) { throw new ServerDBEntityException("Databasen innehåller ej ärendeklass med id " + id); } return(dbentity); }
public static void TryCreate(Account requester, DataContext context, IssueClass issueclass) { if (!requester.IsAtLeastManagement()) { throw new ServerAuthorizeException("Du har inte behörighet att skapa ärendeklass"); } if (context.IssueClasses.Any(i => i.name == issueclass.name)) { throw new ServerConflictException("Ärendeklass med samma namn finns redan"); } issueclass.Validate(); context.IssueClasses.Add(issueclass); }
public static IssueClass TryUpdate(Account requester, DataContext context, IssueClass dbentity) { if (!requester.IsAtLeastManagement()) { throw new ServerAuthorizeException("Du har inte behörighet att uppdatera ärendeklass"); } if (context.IssueClasses.Any(i => i.name == dbentity.name)) { throw new ServerConflictException("Ärendeklass med samma namn finns redan"); } dbentity.Validate(); context.Entry(dbentity).State = System.Data.Entity.EntityState.Modified; return(dbentity); }
public ActionResult ReadIssueClass(int id) { using (var context = new DataContext()) { try { Account account = base.GetLoginAccount(); IssueClass dbm = IssueClassOperations.TryRead(account, context, id); return(Json(new UIIssueClass_CRU(dbm))); } catch (Exception e) { base.HandleException("ReadIssueClass", e); return(null); } } }
public static void TryDelete(Account requester, DataContext context, int id) { if (!requester.IsAtLeastManagement()) { throw new ServerAuthorizeException("Du har inte behörighet att radera ärendeklass"); } // Issues -- delete NOT OK Issue issue = context.Issues.FirstOrDefault(i => id == i.issueclassid); if (issue != null) { throw new ServerConflictException("Ärendeklass används i ärende " + issue.id); } // Do deletion IssueClass dbentity = GetDBEntity(context, id); context.IssueClasses.Remove(dbentity); context.Entry(dbentity).State = System.Data.Entity.EntityState.Deleted; }
public ActionResult CreateIssueClass(UIIssueClass_CRU uim) { AjaxStatus status = new AjaxStatus(); using (var context = new DataContext()) { try { Account account = base.GetLoginAccount(); IssueClass model = uim.CreateModel(); IssueClassOperations.TryCreate(account, context, model); context.SaveChanges(); } catch (Exception e) { base.HandleException("CreateIssueClass", e); status.SetError(e.Message); } } return(Json(status)); }
public IssueClass UpdateModel(IssueClass model) { model.name = this.name; return(model); }
public UIIssueClass_CRU(IssueClass model) { this.id = model.id; this.name = model.name; }