public AnonymousIssueItem GetAnonymousIssueItem() { AnonymousIssueItem item = new AnonymousIssueItem { IssueID = 0, IssueName = String.Empty, IssueDescription = String.Empty, IssueDate = null, IssueTypeID = null, IssueCategoryID = 1, }; item.InitializationType = InitializationTypes.Insert; return(item); }
public AnonymousIssueItem SaveAnonymousIssue(AnonymousIssueItem anonymousIssueItem) { Issue issue = null; switch (anonymousIssueItem.InitializationType) { case InitializationTypes.Insert: issue = new Issue { IssueID = 0, ResidentID = null, IssueName = anonymousIssueItem.IssueName, IssueDescription = anonymousIssueItem.IssueDescription, IssueDate = anonymousIssueItem.IssueDate, IssueTypeID = anonymousIssueItem.IssueTypeID, IssueCategoryID = anonymousIssueItem.IssueCategoryID, CompanyID = null }; db.Issues.Add(issue); break; case InitializationTypes.Update: issue = new Issue { IssueID = anonymousIssueItem.IssueID, ResidentID = null, IssueName = anonymousIssueItem.IssueName, IssueDescription = anonymousIssueItem.IssueDescription, IssueDate = anonymousIssueItem.IssueDate, IssueTypeID = anonymousIssueItem.IssueTypeID, IssueCategoryID = anonymousIssueItem.IssueCategoryID, CompanyID = null }; db.Issues.Attach(issue); db.Entry(issue).State = EntityState.Modified; break; } db.SaveChanges(); anonymousIssueItem.IssueID = issue.IssueID; return(anonymousIssueItem); }