public List <UserActions> GetUserActions
            (List <FileEmployee> fileEmployees, FileDayActions dayActions)
        {
            var ids    = new List <string>();
            var result = new List <UserActions>();

            foreach (var employee in fileEmployees)
            {
                ids.Add(employee.EmployeeId);
            }

            var dbEmployees = _context.Employees
                              .Where(e => ids.Contains(e.EmployeeId))
                              .ToList();

            foreach (var userActions in dayActions.UsersActions)
            {
                var newUserActions = new UserActions(userActions);

                newUserActions.Employee = dbEmployees.Where
                                              (e => e.EmployeeId == userActions.EmployeeId).Single();

                result.Add(newUserActions);
            }

            return(result);
        }
Beispiel #2
0
 public void SaveDayActionsInJsonFile(FileDayActions dayActions)
 {
     using (StreamWriter file = File.CreateText(GetFileNameByDate(dayActions.FormattedDate, ".json")))
     {
         JsonSerializer serializer = new JsonSerializer();
         serializer.Serialize(file, dayActions);
     }
 }
        [HttpPost("/workday/actions")] //localhost:123/workday/actions
        public ActionResult AddDayActions([FromBody] FileDayActions dayActions)
        {
            dayActions.Date = dayActions.Date.LocalFromUtc();
            var fileService = new FileService();

            fileService.SaveDayActionsInJsonFile(dayActions);
            _dbService.AddWorkday();

            return(new EmptyResult());
        }
Beispiel #4
0
 public DayActions(FileDayActions fileDay)
 {
     Date = fileDay.FormattedDate;
 }