public int Update(Vacations Vacation) { try { using (var db = new HCMEntities()) { Vacations VacationObj = db.Vacations.FirstOrDefault(x => x.VacationID.Equals(Vacation.VacationID)); VacationObj.VacationStartDate = Vacation.VacationStartDate; VacationObj.VacationEndDate = Vacation.VacationEndDate; VacationObj.OldBalanceConsumed = Vacation.OldBalanceConsumed; VacationObj.IsCanceled = Vacation.IsCanceled; VacationObj.LastUpdatedBy = Vacation.LastUpdatedBy; VacationObj.LastUpdatedDate = Vacation.LastUpdatedDate; VacationObj.StudiesVacationStartDate = Vacation.StudiesVacationStartDate; VacationObj.SickVacationTypeID = Vacation.SickVacationTypeID; VacationObj.IsSickLeaveAmountPaid = Vacation.IsSickLeaveAmountPaid; VacationObj.NormalVacationTypeID = Vacation.NormalVacationTypeID; return(db.SaveChanges()); } } catch { throw; } }
public int Insert(Vacations Vacation) { try { using (var db = new HCMEntities()) { db.Vacations.Add(Vacation); db.SaveChanges(); return(Vacation.VacationID); } } catch { throw; } }
public int Delete(int VacationID, int UserIdentity) { try { using (var db = new HCMEntities()) { Vacations VacationObj = db.Vacations.FirstOrDefault(x => x.VacationID.Equals(VacationID)); db.Vacations.Remove(VacationObj); return(db.SaveChanges(UserIdentity)); } } catch (Exception ex) { throw ex; } }
public int UpdateVacationDates(Vacations Vacation) { try { using (var db = new HCMEntities()) { Vacations VacationObj = db.Vacations.FirstOrDefault(x => x.VacationID.Equals(Vacation.VacationID)); VacationObj.VacationStartDate = Vacation.VacationStartDate; VacationObj.VacationEndDate = Vacation.VacationEndDate; VacationObj.LastUpdatedBy = Vacation.LastUpdatedBy; VacationObj.LastUpdatedDate = Vacation.LastUpdatedDate; return(db.SaveChanges()); } } catch (Exception ex) { throw ex; } }