public string Update(MarkupPlanViewModel markupPlanViewModel) { int count = (from x in unitOfWork.MarkupPlanRepository.Get() where x.Name == markupPlanViewModel.Name select x.Name).Count(); if (count > 0) { return("Already Exist!!"); } else { var markupPlan = new MarkupPlan { Id = markupPlanViewModel.Id, Name = markupPlanViewModel.Name }; unitOfWork.MarkupPlanRepository.Update(markupPlan); if (unitOfWork.Save() == 1) { return("Successfully Updated"); } else { return("Update Failed"); } } }
public string Delete(int id) { int count = (from x in unitOfWork.MarkupPlanRepository.Get() where x.Id == id select x.Name).Count(); if (count > 0) { var markupPlan = new MarkupPlan { Id = id }; unitOfWork.MarkupPlanRepository.Delete(markupPlan); if (unitOfWork.Save() == 1) { return("Successfully Deleted"); } else { return("Delete Failed"); } } else { return("Id is Not Fount"); } }
public void ShouldMapMarkupPlanToMarkupPlanDto() { var entity = new MarkupPlan(); var result = _mapper.Map <MarkupPlanDto>(entity); result.ShouldNotBeNull(); result.ShouldBeOfType <MarkupPlanDto>(); }
public async Task Handle_ValidCommand_ShouldSaveEntriesSuccessfully(MarkupPlan markupPlan) { // Arrange _mapperMock.Setup(m => m.Map <MarkupPlan>(It.IsAny <CreateMarkupPlanCommand>())) .Returns(markupPlan); // AutoMapper setup var sut = new CreateMarkupPlanCommandHandler(_context, _mapperMock.Object); // creating system under test // Act await sut.Handle(new CreateMarkupPlanCommand(), CancellationToken.None); // Assert _context.MarkupPlans.Count().ShouldBe(1); }
public ActionResult Create(MarkupPlan model) { if (string.IsNullOrWhiteSpace(model.Name)) { ModelState.AddModelError("", "Name Required"); return(View(model)); } try { _context.MarkupPlan.Add(model); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch (Exception e) { ModelState.AddModelError("", e.Message); return(View(model)); } }