public async Task <IActionResult> PutStat(int id, StatDTO stat) { if (id != stat.Id) { return(BadRequest()); } var result = await _stat.Update(stat); await _log.CreateLog(HttpContext, User.FindFirst("UserName").Value); return(Ok(result)); }
private void AddStatResUser(Worker worker) { var WorkerDayStat = CurentDayEnterice(worker.id); if (WorkerDayStat == null || !WorkerDayStat.Any()) { Profile cprofile = profileRepo.GetActive(); DateTime dateTime = DateTime.Now; bool Late = LateWorker(dateTime); string LateTime = null; if (Late) { LateTime = LateTimeCalc(dateTime); } statRepo.Create(new Statistics { StartWork = dateTime, Late = Late, Latetime = LateTime, WorkerID = worker.id });; } else { //add owertime !? DateTime emptyDate = new DateTime(0001, 01, 01, 00, 00, 00); Statistics statistics = WorkerDayStat.FirstOrDefault(a => a.EndWork == emptyDate); if (statistics != null) { statistics.EndWork = DateTime.Now; statRepo.Update(statistics); } else { statRepo.Create(new Statistics { StartWork = DateTime.Now, Late = false, Latetime = null, WorkerID = worker.id });; } } }