public HttpResponseMessage DeleteHolidayList(int holiday_id) { HttpResponseMessage response = null; try { Holiday_List holiday = LeaveRepo.GetHolidayById(holiday_id); if (holiday != null) { LeaveRepo.DeleteHolidayList(holiday); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Success", "Holiday successfully deleted")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_501", "Invalid holiday id", "updated failed")); } } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }
public HttpResponseMessage CreateHoliday(Holiday_List holiday_list) { HttpResponseMessage response = null; try { if (holiday_list != null) { LeaveRepo.CreateHoliday(holiday_list); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Holiday successfully created", "Holiday successfully created")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json")); } } catch (DbEntityValidationException DBexception) { Debug.WriteLine(DBexception.Message); Debug.WriteLine(DBexception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Mandatory fields missing", DBexception.Message)); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }
public static void CreateHoliday(Holiday_List holiday_list) { EMSEntities datacontext = new EMSEntities(); try { datacontext.Holiday_List.Add(holiday_list); datacontext.SaveChanges(); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }
public static void DeleteHolidayList(Holiday_List holiday_list) { EMSEntities datacontext = new EMSEntities(); try { datacontext.Entry(holiday_list).State = EntityState.Deleted; datacontext.SaveChanges(); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.GetBaseException()); throw e; } finally { datacontext.Dispose(); } }