public async void ThrowsGivenNullLotObj() { var lotService = new LotService(null, null, null, null); await Assert.ThrowsAsync <ArgumentNullException>(async() => await lotService.UpdateLotAsync(1, null)); }
public async void ThrowsGivenInvalidLottId() { var lotService = new LotService(_mockLotRepo.Object, null, null, null); await Assert.ThrowsAsync <LotNotFoundException>(async() => await lotService.GetLotWithBidsAsync(_invalidID)); }
public ActionResult doOtherBinDispose() { string lotID = base.Request.Form["lotIDForOtherBinDispose"]; string otherBinDisposeCommentID = base.Request.Form["hidOtherBinDisposeCommentID"]; string str3 = base.Request.Form["txtOtherBinDisposeComment"]; int newPEDispose = Convert.ToInt32(base.Request.Form["hidPEDispose"]); if (StringHelper.isNullOrEmpty(str3)) { str3 = "Other Bin dispose."; } Lot lot = LotService.doOtherBinDispose(lotID, newPEDispose, otherBinDisposeCommentID, str3, BaseController.CurrentUserInfo); NotificationService.ClearNotificationsByRoleAndLotID(UserRoles.PE, lotID, NotificationTypes.LotDispose); NotificationService.ClearNotificationsByRoleAndLotID(UserRoles.PE, lotID, NotificationTypes.OtherBinDispose); if (lot.VenderConfirmed) { NotificationService.CreateOSATConfirmNotificationsWhileLotChanged(lot.VenderID, lot, "OTHERBINDISPOSE"); } ResponseTypes tip = ResponseTypes.Tip; TipTypes information = TipTypes.Information; base.Response.Write(new HandlerResponse("0", "doOtherBinDisposeSuccessed", tip.ToString(), information.ToString(), "", "", lot.Status).GenerateJsonResponse()); return(null); }
protected LotFormViewModel() { LotService = new LotService(); CategoryService = new CategoryService(); Session = Session.CurrentSession; Categories = CategoryService.GetCategories(); ConfirmCommand = new FormCommand(Confirm, ConfirmCanExecute); AddPhotoCommand = new FormCommand(AddPhoto, AddPhotoCanExecute); DeletePhotoCommand = new FormCommand(DeletePhoto); CancelCommand = new FormCommand(ClearForm); Photos = new ObservableCollection <LotContent>(); DaysCount = new List <LotDaysToExpire> { new LotDaysToExpire(3, "3 дня"), new LotDaysToExpire(5, "5 дней"), new LotDaysToExpire(7, "7 дней"), new LotDaysToExpire(10, "10 дней"), new LotDaysToExpire(14, "14 дней"), new LotDaysToExpire(21, "21 день"), new LotDaysToExpire(30, "30 дней") }; ValidatableFieldsNames = new List <string> { nameof(Title), nameof(SelectedCategory), nameof(Description), nameof(StartBid), nameof(SelectedDaysCount) }; }
public ActionResult addLot(Lot lot, int agent) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { Debug.WriteLine(lot); LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); LotService.Add(lot); LotService.Commit(); Affectation affectation = new Affectation { DateAffectation = DateTime.Now, LotId = lot.LotId, EmployeId = agent }; AffectationService.Add(affectation); AffectationService.Commit(); return(RedirectToAction("ConsulterClients", new { numLot = 0, sortOrder = 0 })); } } }
public async Task LotService_SellLot_UpdatesLot() { var bet = new Bet() { Id = 1, UserId = "1", LotId = 1 }; var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(m => m.LotRepository.Update(It.IsAny <Lot>())); mockUnitOfWork .Setup(m => m.LotRepository.GetByIdAsync(It.IsAny <int>())) .ReturnsAsync(GetTestLotsEntities().First()); mockUnitOfWork .Setup(m => m.BetRepository.GetByIdAsync(It.IsAny <int>())) .ReturnsAsync(bet); var lotService = new LotService(mockUnitOfWork.Object, UnitTestHelper.CreateMapperProfile()); var result = await lotService.SellLot(1, bet.Id); Assert.IsTrue(result.Succedeed); mockUnitOfWork.Verify( m => m.LotRepository.Update(It.Is <Lot>( l => l.BuyerId == bet.UserId && !l.IsActive)), Times.Once); mockUnitOfWork.Verify( m => m.SaveAsync(), Times.Once); }
public void LotService_SearchLotModels_ReturnsProperLots() { var minPrice = 500; var maxPrice = 3000; var expected = GetTestLotsModels().Where(l => l.StartPrice > minPrice && l.StartPrice < maxPrice).ToList(); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(m => m.LotRepository.FindAll()).Returns(GetTestLotsEntities().AsQueryable()); var lotService = new LotService(mockUnitOfWork.Object, UnitTestHelper.CreateMapperProfile()); var searchModel = new SearchModel { MinPrice = minPrice, MaxPrice = maxPrice }; var actual = lotService.SearchLotModels(searchModel).ToList(); Assert.AreEqual(expected.Count, actual.Count); for (int i = 0; i < expected.Count; i++) { Assert.AreEqual(expected[i].Id, actual[i].Id); Assert.AreEqual(expected[i].SaleType, actual[i].SaleType); Assert.AreEqual(expected[i].TurnkeyPrice, actual[i].TurnkeyPrice); Assert.AreEqual(expected[i].IsActive, actual[i].IsActive); } }
public void ShouldReturnTrueIfGetLot() { //Arrange string actual = "a"; Mock <IRepository <Lot> > repositoryMock = new Mock <IRepository <Lot> >(); repositoryMock.Setup(a => a.Get(It.IsAny <int>())).Returns(new Lot { Name = "a" }); var unitOfWorkMock = new Mock <IUnitOfWork>(); unitOfWorkMock.Setup(uow => uow.Lots).Returns(repositoryMock.Object); //Act var lotService = new LotService(unitOfWorkMock.Object); var expected = lotService.GetLotById(It.IsAny <int>()).Name; //Assert Assert.AreEqual(expected, actual); }
public void ShuldReturnTrueIfGetLotsWork() { //Arrange Lot one = new Lot { Name = "a", Id = 1 }; LotDTO two = new LotDTO { Name = "a", Id = 1 }; Mock <IRepository <Lot> > repositoryMock = new Mock <IRepository <Lot> >(); repositoryMock.Setup(a => a.GetAll()).Returns(new List <Lot>() { one }); var uowMock = new Mock <IUnitOfWork>(); uowMock.Setup(uow => uow.Lots).Returns(repositoryMock.Object); var lotService = new LotService(uowMock.Object); List <LotDTO> expected = new List <LotDTO>(); expected.Add(two); //Act List <LotDTO> actual = (List <LotDTO>)lotService.GetLots(); //Assert Assert.IsTrue(expected.SequenceEqual(actual, new LotDtoEqualityComparer())); }
private void btnClearSystem_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure to clear ALL lots in LHD system?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { LotService.ClearSystem(); } }
private void doSilicondashService() { while (this.connected) { IList <Lot> lotsBySDStates = LotService.GetLotsBySDStates(this.configuration.OSATID, 0xff); foreach (Lot lot in lotsBySDStates) { try { string str = LotService.GetLotJudgementObject(lot).ToString(); string oldValue = "\"[\\\""; str = str.Replace(oldValue, "[\""); string str3 = "\\\"]\""; str = str.Replace(str3, "\"]"); string data = string.Format("SEND\ndestination:{0}\nreceipt:1\ncontent-type:text/plain;charset=UTF-8;\n\n{1}\0", this.configuration.OutboundChannel, str, str.Length); this.ws.Send(data); lot.SDStates = 1; LotService.UpdateLot(lot); EventService.AppendToLogFileToAbsFile(string.Format(@"{0}\{1}_{2}", this.configuration.MessageOutDirectory, lot.LotNO, DateTime.Now.ToString("yyyyMMddHHmmss")), data); } catch (Exception exception) { EventService.AppendToLogFileToAbsFile(string.Format(@"{0}\TO_SD_{1}_{2}", this.configuration.MessageOutDirectory, lot.LotNO, DateTime.Now.ToString("yyyyMMddHHmmss")), exception.Message); } } Thread.Sleep(0x7530); } }
public ActionResult getCommentList(string lotID, int pageIndex = 0, int pageSize = 5) { int recordCount = 0; IList <Comment> list = null; if ((BaseController.CurrentUserInfo.Role == UserRoles.OSAT) || (BaseController.CurrentUserInfo.Role == UserRoles.OSATAdmin)) { list = LotService.GetCommentsByLotID(lotID, "", true, pageIndex, pageSize, out recordCount); } else { list = LotService.GetCommentsByLotID(lotID, "", false, pageIndex, pageSize, out recordCount); } bool flag = ConfigurationManager.AppSettings["LocalDownload"] == "1"; string str = ConfigurationManager.AppSettings["RemoteDownloadUrlPrefix"]; for (int i = 0; i <= (list.Count - 1); i++) { for (int j = 0; j <= (list[i].Attachments.Count - 1); j++) { if (!flag) { list[i].Attachments[j].StoreRelativePath = str + list[i].Attachments[j].StoreRelativePath; } } } var data = new { currentPage = pageIndex, totalPages = PagerUtility.GetPageCount(recordCount, pageSize), rows = list }; NotificationService.ClearCommentNotificationByUserIDAndLotID(BaseController.CurrentUserInfo.UserID, lotID); return(base.Json(data)); }
public void UpdateLotView(int lotId) { if (lotId == 0) { Lot = new Lot() { Id = 0, Name = "", Quantity = 0, Price = 0, Sum = 0, DeliveryPlace = "Согласно договору", DeliveryTime = "Согласно договору", PaymentTerm = "Согласно договору", Step = 0, Warranty = 0, LocalContent = 0, Dks = 0, ContractNumber = "" }; SelectedUnit = UnitsList[0]; } else { Lot = LotService.ReadLot(lotId); SelectedUnit = UnitsList.FirstOrDefault(u => u.Id == Lot.UnitId); } }
public IEnumerable <SelectListItem> NumLotListForDropDown() { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); List <Lot> Lots = LotService.GetAll().ToList(); List <SelectListItem> listItems = new List <SelectListItem>(); listItems.Add(new SelectListItem { Text = "Tous les lots", Value = "0" }); Lots.DistinctBy(l => l.NumLot).ForEach(l => { listItems.Add(new SelectListItem { Text = "Lot " + l.NumLot, Value = l.NumLot }); }); return(listItems); } } }
private void setConfig(string configFile, string configAga, String path7Zdll) { try { using (StreamReader file = File.OpenText(@configFile)) { JsonSerializer jsonConfig = new JsonSerializer(); this.config = (Config)jsonConfig.Deserialize(file, typeof(Config)); } if (configAga != null) { using (StreamReader file = File.OpenText(@configAga)) { JsonSerializer jsonConfig = new JsonSerializer(); this.configAga = (ConfigAga)jsonConfig.Deserialize(file, typeof(ConfigAga)); } } this.sendService = SendService.getInstance(this.config, this.configAga, path7Zdll); this.lotService = LotService.getInstance(this.config); this.notificationService = NotificationService.getInstance(this.config); } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } }
public ActionResult Test() { LotService ls = new LotService(); ls.ClosingLot(); return(View()); }
public LotServiceTests() { _eventManagerSource.Setup(ems => ems.Create()).Returns(_eventManager.Object); _sut = new LotService( _lotRepository.Object, _instrumentRepository.Object, _eventManagerSource.Object); }
public ActionResult mensuelStatTraite(string year, string month) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); FormulaireService FormulaireService = new FormulaireService(UOW); AffectationService AffectationService = new AffectationService(UOW); EmployeService EmpService = new EmployeService(UOW); int mensuelPoste1Tot = 0; int mensuelPoste2Tot = 0; int mensuelPoste3Tot = 0; int mensuelPoste4Tot = 0; int tot = 0; double mensuelRentaPoste1Tot = 0; double mensuelRentaPoste2Tot = 0; double mensuelRentaPoste3Tot = 0; double mensuelRentaPoste4Tot = 0; double totRenta = 0; List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>(); JoinedList = (from f in FormulaireService.GetAll() join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId join l in LotService.GetAll() on a.LotId equals l.LotId select new ClientAffecteViewModel { Formulaire = f, Affectation = a, Lot = l, }).ToList(); if (month != "" && year != "" && month != null && year != null) { mensuelPoste1Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE1" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count(); mensuelPoste2Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE2" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count(); mensuelPoste3Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE3" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count(); mensuelPoste4Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE4" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count(); tot = mensuelPoste1Tot + mensuelPoste2Tot + mensuelPoste3Tot + mensuelPoste4Tot; mensuelRentaPoste1Tot = rentabiliteAgents(year, month, "POSTE1", LotService, FormulaireService, AffectationService); mensuelRentaPoste2Tot = rentabiliteAgents(year, month, "POSTE2", LotService, FormulaireService, AffectationService); mensuelRentaPoste3Tot = rentabiliteAgents(year, month, "POSTE3", LotService, FormulaireService, AffectationService); mensuelRentaPoste4Tot = rentabiliteAgents(year, month, "POSTE4", LotService, FormulaireService, AffectationService); totRenta = mensuelRentaPoste1Tot + mensuelRentaPoste2Tot + mensuelRentaPoste3Tot + mensuelRentaPoste4Tot; } return(Json(new { tot = tot, mensuelPoste1Tot = mensuelPoste1Tot, mensuelPoste2Tot = mensuelPoste2Tot, mensuelPoste3Tot = mensuelPoste3Tot, mensuelPoste4Tot = mensuelPoste4Tot, totRenta = String.Format("{0:0.00}", totRenta), mensuelRentaPoste1Tot = mensuelRentaPoste1Tot, mensuelRentaPoste2Tot = mensuelRentaPoste2Tot, mensuelRentaPoste3Tot = mensuelRentaPoste3Tot, mensuelRentaPoste4Tot = mensuelRentaPoste4Tot })); } } }
public ActionResult updateLot(ClientAffecteViewModel cavm) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); Lot newlot = LotService.GetById(cavm.Lot.LotId); newlot.Adresse = cavm.Lot.Adresse; newlot.Compte = cavm.Lot.Compte; newlot.DescIndustry = cavm.Lot.DescIndustry; newlot.Emploi = cavm.Lot.Emploi; newlot.IDClient = cavm.Lot.IDClient; newlot.NomClient = cavm.Lot.NomClient; newlot.NumLot = cavm.Lot.NumLot; newlot.PostCode = cavm.Lot.PostCode; newlot.SoldeDebiteur = cavm.Lot.SoldeDebiteur; newlot.TelFixe = cavm.Lot.TelFixe; newlot.TelPortable = cavm.Lot.TelPortable; newlot.Type = cavm.Lot.Type; newlot.Emploi = cavm.Lot.Emploi; LotService.Update(newlot); LotService.Commit(); Affectation affectation = AffectationService.GetById(cavm.Affectation.AffectationId); Debug.WriteLine(cavm.Affectation.EmployeId); if (affectation == null) { Affectation aff = new Affectation { EmployeId = cavm.Affectation.EmployeId, LotId = cavm.Lot.LotId, DateAffectation = DateTime.Now }; AffectationService.Add(aff); AffectationService.Commit(); } else { affectation.EmployeId = cavm.Affectation.EmployeId; affectation.LotId = cavm.Lot.LotId; affectation.DateAffectation = DateTime.Now; AffectationService.Update(affectation); AffectationService.Commit(); } return(RedirectToAction("ConsulterClients", new { numLot = 0, sortOrder = 0 })); } } }
public void AddComment() { string commentID = base.Request.Form["hidNewCommentID"]; string s = base.Request.Form["txtComment"]; s = base.Server.HtmlEncode(s).Replace("\n", "<br/>"); bool internalOnly = base.Request.Form["chkInternal"] != null; LotService.AddNormalComment(LotService.GenerateComment(base.Request.Form["lotID"], -1, commentID, s, internalOnly, BaseController.CurrentUserInfo)); }
private void DeleteLot() { if (SelectedLot == null || SelectedLot.Id == 0) { MessagesService.Show("Удаление лота", "Лот не выбран или не существует"); return; } LotService.DeleteLot(SelectedLot.Id); Init(); }
public ActionResult InformationAboutWinner(int lotId) { LotService ls = new LotService(); BidWinnerDTO bidWinnerDTO = ls.LotWinner(lotId); var config = new MapperConfiguration(cfg => cfg.CreateMap <BidWinnerDTO, BidWinnerViewModel>()); var mapper = new Mapper(config); var bidWinner = mapper.Map <BidWinnerViewModel>(bidWinnerDTO); return(View(bidWinner)); }
public ActionResult AllLots() { LotService ls = new LotService(); IEnumerable <LotDTO> allLotsDTO = ls.AllLotsFromDB(); var config = new MapperConfiguration(cfg => cfg.CreateMap <LotDTO, LotViewModel>()); var mapper = new Mapper(config); var allLots = mapper.Map <IEnumerable <LotViewModel> >(ls.AllLotsFromDB()); return(View(allLots)); }
public ActionResult getSWBin(string lotID, string code, string defect, string qty, string failRate, string isPassed, string limited, string orderBy, bool desc = false, int pageIndex = 0, int pageSize = 5) { int recordCount = 0; IList <SWBin> list = LotService.GetSWBinsBy(lotID, code, defect, qty, failRate, isPassed, limited, orderBy, desc, pageIndex, pageSize, out recordCount); var data = new { currentPage = pageIndex, totalPages = PagerUtility.GetPageCount(recordCount, pageSize), rows = list }; return(base.Json(data)); }
public LotServiceTestSuite() { LotRepositoryMock = new Mock <ILotRepository>(); OrderStateServiceMock = new Mock <IOrderStateService>(); DispatcherServiceMock = new Mock <IDispatcherService>(); LotService = new LotService( LotRepositoryMock.Object, OrderStateServiceMock.Object, DispatcherServiceMock.Object ); }
public void Init() { unitOfWork = new Mock <IUnitOfWork>(); lotModelFactory = new Mock <ILotModelFactory>(); htmlParserProvider = new Mock <IHtmlParserProvider>(); filterModelFactory = new Mock <IFilterModelFactory>(); underTest = new LotService( unitOfWork.Object, htmlParserProvider.Object, lotModelFactory.Object, filterModelFactory.Object); }
public MainLotListing FilterLots([FromServices] LotService lotService) { var filter = new LotFilter { isAllowedIndividual = true, isAllowedJuridic = true, from = 0, to = 2 }; return(lotService.Filter(filter)); }
private void Init(Auction auction) { Procuratory = new Procuratory(); if (auction.Id == 0) { LotsList = new List <Lot>(); } else { LotsList = LotService.ReadLots(auction.Id); } }
protected override void HandleLotAction(LotEntity lot) { lot.StartBid = decimal.Parse(StartBid); lot.CurrentBid = lot.StartBid; lot.DateCreated = DateTime.Now; lot.DateToExpire = DateTime.Now.AddDays(SelectedDaysCount.DaysCount); lot.OwnerId = Session.User.Id; lot.IsActive = true; LotService.AddLot(lot); View.OnLotAction(lot, FormMode.Add); }
public ActionResult BidsForLot(int lotId) { LotService ls = new LotService(); LotDTO lotDto = new LotDTO(); lotDto.BidsForLot = (List <BidDTO>)ls.AllBidsForLot(lotId); var config = new MapperConfiguration(cfg => cfg.CreateMap <BidDTO, BidsForLotViewModel>()); var mapper = new Mapper(config); var bidsForLot = mapper.Map <List <BidsForLotViewModel> >(lotDto.BidsForLot); return(View(bidsForLot)); }