public async Task <CreateProcessStatus> AddSchedule(TimeAndAttendanceScheduleView view) { try { //long timePunchinId = 0; var query = await(from a in _dbContext.TimeAndAttendanceSchedules where a.ScheduleName == view.ScheduleName && a.StartDate == view.StartDate && a.EndDate == view.EndDate && a.ScheduleGroup == view.ScheduleGroup && a.ShiftId == view.ShiftId select a).FirstOrDefaultAsync <TimeAndAttendanceSchedule>(); TimeAndAttendanceSchedule schedule = new TimeAndAttendanceSchedule(); applicationViewFactory.MapTimeAndAttendanceScheduleEntity(ref schedule, view); if (query == null) { AddObject(schedule); return(CreateProcessStatus.Insert); //_dbContext.SaveChanges(); //timePunchinId = taPunchin.TimePunchinId; } return(CreateProcessStatus.AlreadyExists); } catch (Exception ex) { throw new Exception(GetMyMethodName(), ex); } }
public TimeAndAttendanceScheduleView BuildTimeAndAttendanceScheduleView(TimeAndAttendanceSchedule item) { TimeAndAttendanceScheduleView view = applicationViewFactory.MapTimeAndAttendanceScheduleView(item); return(view); }