public static ReturnStatus EditProjectCategory(ProjectCategory cat) { ReturnStatus st = new ReturnStatus(); try { VolunteerDbContext db = new VolunteerDbContext(); db.Entry(cat).State = EntityState.Modified; db.SaveChanges(); st.errorCode = ReturnStatus.ALL_CLEAR; } catch (Exception e) { st.errorCode = ReturnStatus.FAIL_ON_INSERT; st.errorMessage = e.Message; st.data = ""; } return(st); }
public static ReturnStatus CreateProjectCategory(ProjectCategory pc) { ReturnStatus st = new ReturnStatus(); try { VolunteerDbContext db = new VolunteerDbContext(); db.projectCategories.Add(pc); db.SaveChanges(); st.errorCode = ReturnStatus.ALL_CLEAR; st.data = pc; } catch (Exception e) { st.errorCode = ReturnStatus.COULD_NOT_UPDATE_DATABASE; st.errorMessage = e.ToString(); st.data = pc; } return(st); }