Ejemplo n.º 1
0
        public async Task <SaveDutyRosterDetailResponse> UpdateAsync(int id, DutyRosterDetail dutyRoster)
        {
            var existingDutyRoster = await _dutyRosterDetailRepository.FindByIdAsync(id);

            if (existingDutyRoster == null)
            {
                return(new SaveDutyRosterDetailResponse("Duty Roster not found."));
            }

            ///Authorized By NiNiWinMay(Table Joining) 23.6.2019
            existingDutyRoster.Employees.employee_No          = dutyRoster.Employees.employee_No;
            existingDutyRoster.Employees.employee_Name        = dutyRoster.Employees.employee_Name;
            existingDutyRoster.Employees.email                = dutyRoster.Employees.email;
            existingDutyRoster.Employees.dob                  = dutyRoster.Employees.dob;
            existingDutyRoster.Employees.nrc                  = dutyRoster.Employees.nrc;
            existingDutyRoster.Employees.phone_no_work        = dutyRoster.Employees.phone_no_work;
            existingDutyRoster.Employees.phone_no_personal    = dutyRoster.Employees.phone_no_personal;
            existingDutyRoster.Employees.gender               = dutyRoster.Employees.gender;
            existingDutyRoster.Employees.marital_status       = dutyRoster.Employees.marital_status;
            existingDutyRoster.Employees.nationality          = dutyRoster.Employees.nationality;
            existingDutyRoster.Employees.religion             = dutyRoster.Employees.religion;
            existingDutyRoster.Employees.permanent_address    = dutyRoster.Employees.permanent_address;
            existingDutyRoster.Employees.education_background = dutyRoster.Employees.education_background;
            //existingDutyRoster.Employees.addressId=dutyRoster.Employees.addressId;
            existingDutyRoster.Employees.joined_date        = dutyRoster.Employees.joined_date;
            existingDutyRoster.Employees.employee_state     = dutyRoster.Employees.employee_state;
            existingDutyRoster.Employees.Addresses.line_1   = dutyRoster.Employees.Addresses.line_1;
            existingDutyRoster.Employees.Addresses.line_2   = dutyRoster.Employees.Addresses.line_2;
            existingDutyRoster.Employees.Addresses.region   = dutyRoster.Employees.Addresses.region;
            existingDutyRoster.Employees.Addresses.country  = dutyRoster.Employees.Addresses.country;
            existingDutyRoster.DutyRosters.From_Date        = dutyRoster.DutyRosters.From_Date;
            existingDutyRoster.DutyRosters.To_Date          = dutyRoster.DutyRosters.To_Date;
            existingDutyRoster.DutyRosters.Shift.Name       = dutyRoster.DutyRosters.Shift.Name;
            existingDutyRoster.DutyRosters.Shift.Start_Time = dutyRoster.DutyRosters.Shift.Start_Time;
            existingDutyRoster.DutyRosters.Shift.End_Time   = dutyRoster.DutyRosters.Shift.End_Time;

            try
            {
                _dutyRosterDetailRepository.Update(existingDutyRoster);
                await _unitOfWork.CompleteAsync();

                return(new SaveDutyRosterDetailResponse(existingDutyRoster));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new SaveDutyRosterDetailResponse($"An error occurred when saving the Department: {ex.Message}"));
            }
        }
Ejemplo n.º 2
0
        public async Task <SaveDutyRosterDetailResponse> SaveAsync(DutyRosterDetail dutyRoster)
        {
            try
            {
                await _dutyRosterDetailRepository.AddAsync(dutyRoster);

                await _unitOfWork.CompleteAsync();

                return(new SaveDutyRosterDetailResponse(dutyRoster));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new SaveDutyRosterDetailResponse($"An error occurred when saving the Department: {ex.Message}"));
            }
        }
        public async Task <IActionResult> PostAsync([FromBody] DutyRosterDetail dutyRoster)
        {         //get data form _departmentService by id
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            //otherwise data save in database
            var result = await _dutyRosterDetailService.SaveAsync(dutyRoster);

            //if result is not success show error Message
            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            return(Ok());
        }
        public async Task <IActionResult> PutAsync(int id, [FromBody] DutyRosterDetail resource)
        {         // if Model is invalid show error message by using ModelState
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            //get data form EmployeeAttendenceResource by id using AutoMapper
            //var dutyRoster=_mapper.Map<SaveDutyRosterDetailResource,DutyRosterDetail>(resource);
            //update data by id
            var result = await _dutyRosterDetailService.UpdateAsync(id, resource);

            //if update data is null

            if (result == null)
            {
                return(BadRequest(result));
            }
            //get result data from SaveDepartmentResource after update data using automapper
            var roleResource = _mapper.Map <DutyRosterDetail, DutyRosterDetailResource>(result.DutyRosterDetail);

            //show data
            return(Ok(roleResource));
        }
 /// <summary>
 /// Creates a success response.
 /// </summary>
 /// <param name="employee">Saved shipping.</param>
 /// <returns>Response.</returns>
 public SaveDutyRosterDetailResponse(DutyRosterDetail dutyRosterDetail) : this(true, string.Empty, dutyRosterDetail)
 {
     DutyRosterDetail = dutyRosterDetail;
 }
 private SaveDutyRosterDetailResponse(bool success, string message, DutyRosterDetail dutyRosterDetail) : base(success, message)
 {
     DutyRosterDetail = dutyRosterDetail;
 }
 public void Update(DutyRosterDetail dutyRosterDetail)
 {
     _context.DutyRosterDetail.Update(dutyRosterDetail);
 }
 public void Remove(DutyRosterDetail dutyRosterDetail)
 {
     _context.DutyRosterDetail.Remove(dutyRosterDetail);
 }
 public async Task AddAsync(DutyRosterDetail dutyRosterDetail)
 {
     await _context.DutyRosterDetail.AddAsync(dutyRosterDetail);
 }