Example #1
0
        public async Task <IActionResult> UpdateUserShift([FromBody] UpdateUserDto updatedUser)
        {
            var newUser = new User
            {
                UserId       = updatedUser.UserId,
                AccountId    = updatedUser.AccountId,
                FirstName    = updatedUser.FirstName,
                LastName     = updatedUser.LastName,
                Gender       = updatedUser.Gender,
                DepartmentId = updatedUser.DepartmentId,
                PositionId   = updatedUser.PositionId
            };
            await _userShiftRepo.DeleteAsync(d => d.UserId == updatedUser.UserId);

            await _userRepo.UpdateAsync(newUser);

            if (updatedUser.UserShifts.Count > 0)
            {
                foreach (var userShift in updatedUser.UserShifts)
                {
                    var newUserShift = new UserShift
                    {
                        ShiftId = userShift.ShiftId,
                        UserId  = userShift.UserId,
                        Day     = userShift.Day
                    };
                    await _userShiftRepo.CreateAsync(newUserShift);
                }
            }
            return(Ok(await GetUserList()));
        }
Example #2
0
        public async Task <IActionResult> UpdateLeaveInfo([FromBody] List <LeaveRequest> leave)
        {
            foreach (var leavedata in leave)
            {
                var newleavedata = new LeaveRequest
                {
                    LeaveRequestId  = leavedata.LeaveRequestId,
                    UserId          = leavedata.UserId,
                    StartDate       = leavedata.StartDate,
                    EndDate         = leavedata.EndDate,
                    IsApproved      = leavedata.IsApproved,
                    LeaveCategoryId = leavedata.LeaveCategoryId
                };

                await _leaveReqRepo.UpdateAsync(newleavedata);
            }
            return(Ok(await GetLeaveList()));
        }