public new void Setup() { this.contractorServiceMock = new Mock <IContractorService>(); this.sut = new ContractorsController(this.contractorServiceMock.Object); this.contractor = this.Fixture.Build <ContractorDto>().Create(); }
// GET: Employe/Edit/5 public ActionResult Edit(int?id) { ContractorModel contractorModel = new ContractorModel(); InitializePageData(); if (!id.HasValue) { DisplayWarningMessage("Looks like, the Contractor ID is missing in your request"); return(View(contractorModel)); } try { if (!contractService.Exists(id.Value)) { DisplayWarningMessage($"Sorry, we couldn't find the Employee with ID: {id.Value}"); return(View(contractorModel)); } ContractorDto contractor = contractService.GetByID(id.Value); contractorModel = Mapper.Map <ContractorDto, ContractorModel>(contractor); } catch (Exception exp) { DisplayReadErrorMessage(exp); } return(View(contractorModel)); }
public ActionResult Edit(ContractorModel contractor) { try { InitializePageData(); if (ModelState.IsValid) { if (contractService.IsDuplicateContractorName(contractor.ContractorID, contractor.ContractorName)) { DisplayWarningMessage("There is already a Contractor with the same Name"); return(View(contractor)); } ContractorDto contractorDto = Mapper.Map <ContractorModel, ContractorDto>(contractor); contractService.UpdateContractor(contractorDto); DisplaySuccessMessage("Contractor details have been Updated successfully"); return(RedirectToAction("List")); } } catch (Exception exp) { DisplayUpdateErrorMessage(exp); } return(View(contractor)); }
public async Task <IActionResult> UpdateContractor(int id, [FromBody] ContractorDto model) { var response = await _clientService.PutAsync($"{_settings.Value.OilApiAddress}Contractor/UpdateContractor/{id}", model); var content = await response.Content.ReadAsStringAsync(); return(new ObjectResult(content)); }
public void Add(ContractorDto entity) { Contractor employee = CreateBusinessEntity(entity, true); Entities.Add(employee); DataContext.Entry(employee).State = EntityState.Added; DataContext.SaveChanges(); }
public void Delete(ContractorDto entity) { Contractor buzEntity = Entities.FirstOrDefault(e => e.ContractorID == entity.ContractorID); buzEntity.IsDeleted = true; buzEntity.UpdateTimeStamp(entity.LoggedInUserName); Entities.Add(buzEntity); DataContext.Entry(buzEntity).State = EntityState.Modified; DataContext.SaveChanges(); }
public async Task <ContractorDto> CreateContractor(ContractorDto contractorDto) { var contractor = this.Mapper.Map <Contractor>(contractorDto); contractor.AssignHealthStatus(); await this.context.Contractors.AddAsync(contractor); await this.context.SaveChangesAsync(); return(this.Mapper.Map <ContractorDto>(contractor)); }
public void BizAction(ContractorDto inputData) { var contractor = _dbAccess.GetContractor(inputData.Id); if (contractor == null) { throw new NullReferenceException("Could not find the contractor. Someone entering illegal ids?"); } var status = contractor.UpdateContractor(inputData.Name, inputData.PhoneNumber, inputData.Address, inputData.ContractDate); CombineErrors(status); Message = $"contractor is update: {contractor.ToString()}."; }
private void MigrateEntity(ContractorDto sourceEntity, Contractor targetEntity) { targetEntity.AgilisiumManagerID = sourceEntity.AgilisiumManagerID; targetEntity.BillingRate = sourceEntity.BillingRate; targetEntity.ClientRate = sourceEntity.ClientRate; targetEntity.ContractorID = sourceEntity.ContractorID; targetEntity.ContractorName = sourceEntity.ContractorName; targetEntity.ContractPeriodID = sourceEntity.ContractPeriodID; targetEntity.EndDate = sourceEntity.EndDate; targetEntity.OnshoreRate = sourceEntity.OnshoreRate; targetEntity.ProjectID = sourceEntity.ProjectID; targetEntity.SkillSet = sourceEntity.SkillSet; targetEntity.StartDate = sourceEntity.StartDate; targetEntity.VendorID = sourceEntity.VendorID; targetEntity.UpdateTimeStamp(sourceEntity.LoggedInUserName); }
public IActionResult UpdateContractor(int id, ContractorDto model, [FromServices] IActionService <IUpdateContractorAction> service) { model.Id = id; service.RunBizAction(model); if (!service.Status.HasErrors) { return(new ObjectResult(new ResultResponseDto <String, int> { Key = HttpStatusCode.OK, Value = "Contractor updated.." })); } var errors = service.Status.CopyErrorsToString(ModelState); return(new ObjectResult(new ResultResponseDto <String, int> { Key = HttpStatusCode.BadRequest, Value = errors, Subject = model.Id })); }
public IActionResult CreateContractor(ContractorDto model, [FromServices] IActionService <IPlaceContractorAction> service) { var contractor = service.RunBizAction <Contractor>(model); if (!service.Status.HasErrors) { return(new ObjectResult(new ResultResponseDto <String, int> { Key = HttpStatusCode.OK, Value = "Contractor created..", Subject = contractor.Id })); } var errors = service.Status.CopyErrorsToString(ModelState); service.Status.CopyErrorsToString(ModelState); return(new ObjectResult(new ResultResponseDto <String, int> { Key = HttpStatusCode.BadRequest, Value = errors })); }
public Contractor BizAction(ContractorDto inputData) { if (string.IsNullOrWhiteSpace(inputData.Name)) { AddError("Contractor Name is Required."); return(null); } var desStatus = Contractor.CreateContractor(inputData.Name, inputData.PhoneNumber, inputData.Address, inputData.ContractDate); CombineErrors(desStatus); if (!HasErrors) { _dbAccess.Add(desStatus.Result); } return(HasErrors ? null : desStatus.Result); }
private Contractor CreateBusinessEntity(ContractorDto contractorDto, bool isNewEntity = false) { Contractor contractor = new Contractor { AgilisiumManagerID = contractorDto.AgilisiumManagerID, BillingRate = contractorDto.BillingRate, ClientRate = contractorDto.ClientRate, ContractorID = contractorDto.ContractorID, ContractorName = contractorDto.ContractorName, ContractPeriodID = contractorDto.ContractPeriodID, EndDate = contractorDto.EndDate, OnshoreRate = contractorDto.OnshoreRate, ProjectID = contractorDto.ProjectID, SkillSet = contractorDto.SkillSet, StartDate = contractorDto.StartDate, VendorID = contractorDto.VendorID, }; contractor.UpdateTimeStamp(contractorDto.LoggedInUserName, true); return(contractor); }
private static List <ContractorDto> PrintShortestPath( ContractorDto fromContractor, ContractorDto toContractor, IReadOnlyDictionary <ContractorDto, ContractorDto> nodeDictionary) { var result = new List <ContractorDto>(); if (toContractor == null) { return(new List <ContractorDto>()); } var currentNode = toContractor; while (currentNode != fromContractor) { result.Add(currentNode); currentNode = nodeDictionary[currentNode]; } result.Add(fromContractor); result.Reverse(); return(result); }
public void Delete(ContractorDto contractor) { repository.Delete(contractor); }
public AddNewContractorCommand(ContractorDto contractor) : base(Guid.NewGuid(), "Anonymous") { //TODO: pass actual user who submitted the command Contractor = contractor; }
public void CreateNewContractor(ContractorDto contractor) { repository.Add(contractor); }
public IHttpActionResult Save(ContractorDto contractortoDb) { Console.WriteLine("Save"); try { var contractorInDb = Db.Contractors.Find(contractortoDb.EmployeeID, contractortoDb.ContractorID); //update if (contractorInDb != null) { contractorInDb.IdCard = contractortoDb.IdCard; contractorInDb.ContractorID = contractortoDb.ContractorID; contractorInDb.VoucherID = contractorInDb.VoucherID; contractorInDb.Name = contractortoDb.Name; contractorInDb.Phone = contractortoDb.Phone; contractorInDb.Birthday = contractortoDb.Birthday; contractorInDb.Sex = contractortoDb.Sex; contractorInDb.Job = contractortoDb.Job; contractorInDb.Region = contractortoDb.Region; contractorInDb.Remark = contractortoDb.Remark; if (contractortoDb.Status == "N" || contractortoDb.Status == "X") { contractorInDb.Status = contractortoDb.Status; } else { contractorInDb.Status = contractortoDb.IsUpdate ? "Q" : "F"; } contractorInDb.PreStatus = contractortoDb.Status; contractorInDb.Stamp = DateTime.Now; contractorInDb.UserId = contractortoDb.UserId; contractorInDb.TrainDate = contractortoDb.TrainDate; contractorInDb.AppointmentDate = contractortoDb.AppointmentDate; contractorInDb.EmployeeID = contractorInDb.EmployeeID; contractorInDb.ReasonReturn = null; Db.Entry(contractorInDb).State = EntityState.Modified; } else { contractorInDb = new Contractor { VoucherID = contractortoDb.VoucherID, EmployeeID = oAC.SelectScalar <string>("select dbo.fnContractorEmployeeID(@typeID)", new object[] { "Employee" }), IdCard = contractortoDb.IdCard, Name = contractortoDb.Name, ContractorID = contractortoDb.ContractorID, Phone = contractortoDb.Phone, Birthday = contractortoDb.Birthday, Sex = contractortoDb.Sex, Job = contractortoDb.Job, Region = contractortoDb.Region, Remark = contractortoDb.Remark, Status = contractortoDb.Status, PreStatus = contractortoDb.Status, Stamp = DateTime.Now, UserId = contractortoDb.UserId, TrainDate = contractortoDb.TrainDate, AppointmentDate = contractortoDb.AppointmentDate }; Db.Contractors.Add(contractorInDb); var _biometric = new ContractorBiometric { EmployeeID = contractorInDb.EmployeeID, CardNo = null, FaceTmp = null, IsValid = 0 }; Db.ContractorBiometrics.Add(_biometric); } Db.SaveChanges(); return(Ok()); } catch (Exception e) { Loger.Error(e); return(BadRequest(e.Message)); } }
public async Task <IActionResult> CreateContractor([FromBody] ContractorDto contractor) { var newContractor = await this.contractorService.CreateContractor(contractor); return(this.CreatedAtAction(nameof(this.CreateContractor), newContractor)); }
public void UpdateContractor(ContractorDto contractor) { repository.Update(contractor); }