public async Task <ActionResult> Post(PunchDto punchDto) { try { var validator = new PunchDtoValidator(); var result = validator.Validate(punchDto); if (!result.IsValid) { return(BadRequest(result.Errors)); } var punchViewModel = new PunchViewModel { EmployeeId = punchDto.EmployeeId, EmployeeName = punchDto.EmployeeName, PunchType = punchDto.PunchType }; await _punchService.Register(punchViewModel); return(Ok()); } catch (Exception ex) { return(BadRequest(ex)); } }
public static void SetPunch(this PunchDto punchDto, Punch punch) { punchDto.Created = punch.Created; punchDto.Direction = punch.Direction; punchDto.Punchid = punch.Id; punchDto.Time = punch.PunchTime; punchDto.Timedec = (double)punch.TimeDec; punchDto.Updated = punch.Updated; }
private void Ready() { SetReceiveTimeout(TimeSpan.FromSeconds(5)); var stopwatch = Stopwatch.StartNew(); Command <GetHits>(_ => { Sender.Tell(_state.Hits); }); Command <Kick>(message => { Logger.Info("{Id} received {Type}.", PersistenceId, message.GetType().Name); var dto = new KickDto(Guid.NewGuid(), DateTime.UtcNow, message.Force); Save(dto, () => { Sender.Tell("DONE"); }); }); Command <Punch>(message => { Logger.Info("{Id} received {Type}.", PersistenceId, message.GetType().Name); var dto = new PunchDto(Guid.NewGuid(), DateTime.UtcNow, message.Speed); Save(dto, () => { Sender.Tell("DONE"); }); }); Command <Slap>(message => { Logger.Info("{Id} received {Type}.", PersistenceId, message.GetType().Name); var dto = new SlapDto(Guid.NewGuid(), DateTime.UtcNow, message.SassFactor); Save(dto, () => { Sender.Tell("DONE"); }); }); Command <SaveSnapshotSuccess>(success => Logger.Debug("Saved snapshot {SequenceNr}.", success.Metadata.SequenceNr)); Command <SaveSnapshotFailure>(failure => Logger.Error(failure.Cause, "Failed to save snapshot {SequenceNr}.", failure.Metadata)); Command <ReceiveTimeout>(_ => { Logger.Info("Received timeout after {Duration}ms. Stopping Actor.", stopwatch.ElapsedMilliseconds); Context.Stop(Self); }); }
public Punch BizAction(PunchDto inputData) { if (string.IsNullOrWhiteSpace(inputData.Code)) { AddError("Code is Required."); return(null); } var activity = _activityDbAccess.GetActivityToPunches(inputData.ActivityId); if (activity == null) { AddError("activity not valid!!!", "Activity"); return(null); } if (activity.Status != Common.ActivityStatus.Done) { AddError("Activity is not completed and don't allow for add punch!!!", "Activity"); return(null); } var punchType = _dbAccessPunchType.GetPunchTypeToWorkPackages(inputData.PunchTypeId); if (punchType == null) { AddError("Invalied punch Type!!!", "Activity"); return(null); } var desStatus = Punch.CreatePunch(inputData.Code, inputData.DefectDescription, inputData.OrginatedBy, inputData.CreatedBy, inputData.CheckBy , inputData.ApproveBy, inputData.OrginatedDate, inputData.CheckDate, inputData.ClearDate, inputData.EstimateMh, inputData.ActualMh, inputData.VendorRequired, inputData.VendorName, inputData.MaterialRequired, inputData.EnginerigRequired, inputData.ClearPlan, inputData.CorectiveAction , inputData.PunchTypeId, inputData.ActivityId, inputData.CategoryId); CombineErrors(desStatus); if (!HasErrors) { _dbAccess.Add(desStatus.Result); } return(HasErrors ? null : desStatus.Result); }
public void BizAction(PunchDto inputData) { var punch = _dbAccess.GetPunch(inputData.Id); if (punch == null) { AddError("Could not find the punch. Someone entering illegal ids?"); return; } var status = punch.UpdatePunch(inputData.DefectDescription, inputData.OrginatedBy, inputData.CreatedBy, inputData.CheckBy , inputData.ApproveBy, inputData.OrginatedDate, inputData.CheckDate, inputData.ClearDate, inputData.EstimateMh, inputData.ActualMh, inputData.VendorRequired, inputData.VendorName, inputData.MaterialRequired, inputData.EnginerigRequired, inputData.ClearPlan, inputData.CorectiveAction ); CombineErrors(status); Message = $"punch is update: {punch.ToString()}."; }