public void Update(SampleDTO sampleDTO) { // Validation if (sampleDTO.Name.Length > 25) { throw new ValidationException($"The length of {nameof(sampleDTO.Name)} must be less then 25" , nameof(sampleDTO.Name)); } if (sampleDTO.Description.Length > 255) { throw new ValidationException($"The length of {nameof(sampleDTO.Description)} must be less then 25" , nameof(sampleDTO.Description)); } if (sampleDTO == null) { throw new ArgumentNullException($"null object({nameof(sampleDTO)}) can not be passed to Update method of base service"); } var sample = SampleMapper.Map <SampleDTO, Sample>(sampleDTO); Uow.Samples.Update(sample); Uow.Save(); }
public void Get_WhenRequestByExistedItemId_ReturnsItem() { //Arrange var sample = new Sample { SampleId = 1, Description = "Description_1", Name = "Name_1" }; _sampleRepository.Setup(r => r.Get(1)).Returns(sample); var sampleDTO = new SampleDTO { SampleId = 1, Description = "Description_1", Name = "Name_1" }; _mapper.Setup(r => r.Map <Sample, SampleDTO>(sample)).Returns(sampleDTO); //Act var actual = _sampleService.Get(1); //Assert _sampleRepository.Verify(r => r.Get(It.Is <int>(v => v == 1))); Assert.That(actual, Is.Not.Null); Assert.That(actual, Has .Property("Description") .EqualTo("Description_1")); }
public void Get() { var dto = new SampleDTO { Id = "1" }; var business = _mapper.Map(dto); }
public bool DeleteById(long Id) { SampleDTO newUser = new SampleDTO(); IUnitOfWork _unitOfWork = new UnitOfWork(_ctx); ISampleRepository _sampleRepository = new SampleRepository(_ctx); var _sampleService = new SampleService(_unitOfWork, _sampleRepository); return(_sampleService.DeleteById(Id)); }
public void Add_NewItem_CreateAndSaveMethodsCompleted() { var sampleDTO = new SampleDTO { SampleId = 1, Description = "Description_1", Name = "Name_1" }; _sampleService.Add(sampleDTO); _sampleRepository.Verify(r => r.Add(It.IsAny <Sample>())); _unitOfWork.Verify(r => r.Save()); }
public bool DeleteById(long Id) { SampleDTO dto = new SampleDTO() { Id = Id }; Sample sample = Mapper.Map <Sample>(dto); return(_SampleRepository.DeleteById(Id)); }
private static ContractTransaction prepareDeployObject(string bindingID, Order orderObject) { var accomodation = orderObject.Consignments[0].AccommodationData; var activity = orderObject.Consignments[0].ActivityData; SampleDTO _dto = new SampleDTO() { ContractID = bindingID, TransactionID = bindingID, TransactedTime = DateTime.Now, Description = "Transacted", AdminDetail = new AdminDetails() { OrderCode = orderObject.OrderCode, ConsignmentCode = orderObject.Consignments[0].Code, ConsignmentStatus = orderObject.Consignments[0].Status, BookingDate = orderObject.BookingDate.ToString(), CheckinDate = accomodation == null ? null : accomodation.CheckIn.ToString(), CheckoutDate = accomodation == null ? null : accomodation.CheckOut.ToString(), Currency = orderObject.Currency, Quantity = "1", Price = orderObject.OrderPrice.ToString(), ServiceDate = DateTime.Now.ToString(), ServiceType = orderObject.Consignments[0].Type, Supplier = orderObject.Supplier } }; ConstructorConfirmation _deployConfirmation = new ConstructorConfirmation() { BindingId = bindingID, Name = "New Enterprise Smart Contract instance", TransactionConfirmation = new TransactionConfirmation() { BlockHash = "0xfa4e2a31506c1f930efc7701ff6ddc1451d08a38a7a9267fe263766b4c7ea2d0", BlockNumber = "1", ContractAddress = "0xed9d02e382b34818e88b88a309c7fe71e65f419d", TransactionHash = "", ContractName = "", ProxyId = "", TransactionIndex = "1" } }; ContractTransaction _txInformation = new ContractTransaction(_dto, _deployConfirmation); _txInformation.OrderDetails = orderObject; return(_txInformation); }
public ActionResult DisplaySample(long?id) { try { SampleDTO sample = sampleService.GetSample(id); Mapper.Initialize(cfg => cfg.CreateMap <SampleDTO, SampleViewModel>()); var model = Mapper.Map <SampleDTO, SampleViewModel>(sample); return(View(model)); } catch (ValidationException ex) { return(Content(ex.Message)); } }
public void Update_ExistedItem_UpdateAndSaveMethodsCompleted() { var sample = new Sample { SampleId = 1, Description = "Description_1", Name = "Name_1" }; _sampleRepository.Setup(r => r.Update(sample)); var sampleDTO = new SampleDTO { SampleId = 1, Description = "Description_1", Name = "Name_1" }; _sampleService.Update(sampleDTO); _sampleRepository.Verify(r => r.Update(It.IsAny <Sample>())); _unitOfWork.Verify(r => r.Save()); }
public IActionResult Contact() { ViewData["Message"] = string.Format("New MVC is {0} times better than the old one. You can get it for only ${1}", TimesBetterThanWindows, businessBro.GetSwag()); ViewData["DbData"] = sampleDataAccess.GetAttachmentName(1200); try { SampleDTO dto = GetPostedData(); ViewData["SampleResultID"] = dto.id; ViewData["SampleResultBody"] = dto.body; } catch (Exception e) { ViewData["Error"] = e.Message; } return(View()); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SampleDTO sampleDto = _sampleService.GetSample(id.Value); if (sampleDto == null) { return(HttpNotFound()); } var sample = _mapper.Map <SampleDTO, SampleViewModel>(sampleDto); return(View(sample)); }
public bool Update() { SampleDTO newUser = new SampleDTO(); IUnitOfWork _unitOfWork = new UnitOfWork(_ctx); ISampleRepository _sampleRepository = new SampleRepository(_ctx); var _sampleService = new SampleService(_unitOfWork, _sampleRepository); newUser = _sampleService.GetById(2); // newUser.Name = "Priya B"; Sample userList = Mapper.Map <Sample>(newUser); // _sampleService.Update(userList); // message = _sampleService.Add(newUser); return(_sampleService.UpdateById(1)); }
public OperationDetails AddSample(SampleDTO sampleDto) { var matched = unitOfWork.SampleRepository.Get(c => c.Name.ToLower() == sampleDto.Name.ToLower()); if (matched.Count() > 0) { throw new ValidationException("Name already exists !!!", "Name"); } Sample sample = new Sample() { Name = sampleDto.Name }; unitOfWork.SampleRepository.Insert(sample); unitOfWork.Save(); return(new OperationDetails(true, "Sample inserted Successfully", "")); }
public void Get_WhenRequestByNotExistedItemId_ReturnsNull() { //Arrange var sample = new Sample { SampleId = 1, Description = "Description_1", Name = "Name_1" }; _sampleRepository.Setup(r => r.Get(1)).Returns(sample); var sampleDTO = new SampleDTO { SampleId = 1, Description = "Description_1", Name = "Name_1" }; _mapper.Setup(r => r.Map <Sample, SampleDTO>(sample)).Returns(sampleDTO); //Act SampleDTO actual = _sampleService.Get(2); //Assert Assert.That(actual, Is.Null); }
public ActionResult Delete(int?id, bool?saveChangesError = false) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator."; } SampleDTO sampleDto = _sampleService.GetSample(id.Value); if (sampleDto == null) { return(HttpNotFound()); } var sample = _mapper.Map <SampleDTO, SampleViewModel>(sampleDto); return(View(sample)); }
public void UpdateSample(SampleDTO sampleDTO) { // Validation if (sampleDTO.Name.Length > 25) { throw new ValidationException($"The length of {nameof(sampleDTO.Name)} must be less then 25" , nameof(sampleDTO.Name)); } if (sampleDTO.Description.Length > 255) { throw new ValidationException($"The length of {nameof(sampleDTO.Description)} must be less then 25" , nameof(sampleDTO.Description)); } var sample = Database.Samples.Get(sampleDTO.SampleId); if (sample != null) { Mapper.Map(sampleDTO, sample); Database.Save(); } }
public void Add(SampleDTO sampleDTO) { // Validation if (sampleDTO.Name.Length > 25) { throw new ValidationException($"The length of {nameof(sampleDTO.Name)} must be less then 25" , nameof(sampleDTO.Name)); } if (sampleDTO.Description.Length > 255) { throw new ValidationException($"The length of {nameof(sampleDTO.Description)} must be less then 25" , nameof(sampleDTO.Description)); } var sample = new Sample { Name = sampleDTO.Name, Description = sampleDTO.Description }; Uow.Samples.Add(sample); Uow.Save(); }
public void SaveSample(SampleDTO sampleTM) { // Validation if (sampleTM.Name.Length > 25) { throw new ValidationException($"The length of {nameof(sampleTM.Name)} must be less then 25" , nameof(sampleTM.Name)); } if (sampleTM.Description.Length > 255) { throw new ValidationException($"The length of {nameof(sampleTM.Description)} must be less then 25" , nameof(sampleTM.Description)); } var sample = new Sample { Name = sampleTM.Name, Description = sampleTM.Description }; Database.Samples.Create(sample); Database.Save(); }
protected override void OnInit(IDotvvmRequestContext context) { Data = new SampleRenderer().GetSampleHtml(SampleName); base.OnInit(context); }