Example #1
0
        public ActionResult Buyer(BuyerViewModel model)
        {
            if (ModelState.IsValid)
            {
                var db         = new ApplicationDbContext();
                var accessCode = db.AccessCodes.SingleOrDefault(AccessCode => AccessCode.BuyerEmail == model.Email);
                ViewBag.AccountNumber = "Not Available";
                ViewBag.AccountName   = "Not Available";

                if (accessCode != null)
                {
                    if (accessCode.UniqueCode == model.AccessCode)
                    {
                        var invoiceAccount = db.InvoiceAccounts.Single(InvoiceAccount => InvoiceAccount.InvoiceAccountId == accessCode.InvoiceAccountId);

                        Task.Run(async() =>
                        {
                            var userId  = User.Identity.GetUserId();
                            var address = db.Companies.Where(a => a.ApplicationUserId == userId).Select(a => a.Address).ToList <string>();
                            var eth     = new Ethereum(address[0]);
                            var result  = await eth.ExecuteContractView("h@ck3r00", accessCode.BuyerEmail, invoiceAccount.AccountNumber);

                            if (result == "Valid account")
                            {
                                ViewBag.AccountNumber = invoiceAccount.AccountNumber;
                                ViewBag.AccountName   = invoiceAccount.AccountName;
                            }
                        }).Wait();
                    }
                }
            }

            return(View());
        }
        public async Task Post_Failed_Internal_Server_Error()
        {
            BuyerViewModel VM       = null;
            var            response = await this.Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(VM).ToString(), Encoding.UTF8, "application/json"));

            Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
        }
Example #3
0
        //Статистика по клиентам
        private void BuyerStatistic()
        {
            Dictionary <int, int> buyerDict
                = new Dictionary <int, int>();

            for (int i = 0; i < archiveBid.Count; i++)
            {
                if (!buyerDict.ContainsKey(archiveBid[i].Id_buyer))
                {
                    buyerDict.Add(archiveBid[i].Id_buyer, 1);
                }
                else
                {
                    buyerDict[archiveBid[i].Id_buyer]++;
                }
            }
            if (buyerDict.Count == 0)
            {
                return;
            }

            ReportRow rowH = new ReportRow();

            rowH.Add(new ReportCell("Статистика по клиентам:"));
            Rows.Add(rowH);

            ReportRow rowT = new ReportRow();

            rowT.Add(new ReportCell("Покупатель")
            {
                BorderColor = System.Drawing.Color.Black, ColumnSpan = 1
            });
            rowT.Add(null);
            rowT.Add(new ReportCell("Кол-во заявок")
            {
                ColumnSpan = 1, BorderColor = System.Drawing.Color.Black
            });
            Rows.Add(rowT);

            foreach (KeyValuePair <int, int> kv in buyerDict.OrderByDescending(x => x.Value))
            {
                Buyer buyer = BuyerViewModel.instance().getById(kv.Key);
                if (buyer == null)
                {
                    continue;
                }

                ReportRow row = new ReportRow();
                row.Add(new ReportCell(buyer.Name)
                {
                    ColumnSpan = 1, BorderColor = System.Drawing.Color.Black
                });
                row.Add(null);
                row.Add(new ReportCell(kv.Value.ToString())
                {
                    ColumnSpan = 1, BorderColor = System.Drawing.Color.Black
                });
                Rows.Add(row);
            }
        }
Example #4
0
        public JsonResult Post([FromBody] BuyerViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var newBuyer = Mapper.Map <Buyer>(viewModel);
                    _logger.LogInformation("Attemping to save new Buyer");
                    _repository.AddBuyer(newBuyer);

                    if (_repository.SaveAll())
                    {
                        Response.StatusCode = (int)HttpStatusCode.Created;
                        return(Json(Mapper.Map <BuyerViewModel>(newBuyer)));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to save new Buyer", ex);
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Message = ex.Message }));
            }

            return(Json("Failed!"));
        }
Example #5
0
        public void ValidateDefault()
        {
            BuyerViewModel viewModel = new BuyerViewModel();
            var            result    = viewModel.Validate(null);

            Assert.True(result.Count() > 0);
        }
Example #6
0
        // GET: Buyers/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var buyer = new BuyerViewModel();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseUrl);
                //HTTP GET
                HttpResponseMessage responseTask = await client.GetAsync($"Buyers/{id.Value}");

                if (responseTask.IsSuccessStatusCode)
                {
                    var readTask = await responseTask.Content.ReadAsAsync <BuyerViewModel>();

                    buyer = readTask;

                    return(View(buyer));
                }

                ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
            }
            return(View(buyer));
        }
Example #7
0
        public async Task Post()
        {
            BuyerViewModel VM       = GenerateTestModel();
            var            response = await this.Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(VM).ToString(), Encoding.UTF8, "application/json"));

            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
        }
        public void Should_Return_Error_2_Update_Data()
        {
            Mock <IBuyerFacade> mockBuyerFacade = new Mock <IBuyerFacade>();

            mockBuyerFacade.Setup(p => p.UpdateById(It.IsAny <Buyer>())).Returns(0);
            mockBuyerFacade.Setup(p => p.ReadById(It.IsAny <int>())).Returns(buyerDataUtil.GetModelData());

            Mock <IServiceProvider> mockServiceProvider = new Mock <IServiceProvider>();

            mockServiceProvider.Setup(p => p.GetService(typeof(IBuyerFacade))).Returns(mockBuyerFacade.Object);
            mockServiceProvider.Setup(p => p.GetService(typeof(ProjectDbContext))).Returns(MemoryDbHelper.GetDB(Helper.GetCurrentMethod(ENTITY)));

            Mock <IMapper> mockMapper = new Mock <IMapper>();

            mockMapper.Setup(p => p.Map <Buyer>(It.IsAny <BuyerViewModel>()))
            .Returns(buyerDataUtil.GetModelData());

            BuyersController buyersController = new BuyersController(mockServiceProvider.Object, mockMapper.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                }
            };

            buyersController.ControllerContext.HttpContext.Request.Path = new PathString("/v1/unit-test");

            BuyerViewModel viewModel = buyerDataUtil.GetViewModelData();
            IActionResult  result    = buyersController.Put(1, viewModel);

            Assert.Equal(HttpStatusCode.InternalServerError, (HttpStatusCode)((ObjectResult)result).StatusCode);
        }
Example #9
0
        public async Task <IdentityResult> Register(BuyerViewModel vm)
        {
            DbUser newUser = new DbUser
            {
                Name        = vm.Name,
                UserName    = vm.UserName,
                Email       = vm.Email,
                PhoneNumber = vm.PhoneNumber
            };

            var result = await userManager.CreateAsync(newUser, vm.Password);

            if (result.Succeeded)
            {
                //var roleResult = await userManager.AddToRoleAsync(newUser, "buyer");
                //if (roleResult.Succeeded)
                //{
                await signInManager.SignInAsync(newUser, isPersistent : false);

                //}
                //else
                //{
                //    return roleResult;
                //}
            }
            return(result);
        }
Example #10
0
        public ActionResult Edit(BuyerViewModel viewModel)
        {
            var req = viewModel.MapTo <SaveBuyerRequest>();

            _buyerService.SaveBuyer(req);
            return(RedirectToAction("Index"));
        }
Example #11
0
        //
        // GET: /Buyer/Create
        public ActionResult Create()
        {
            var viewModel = new BuyerViewModel();

            viewModel.IsActive = true;
            return(View(viewModel));
        }
        private void SetBuyerSource()
        {
            Bid     bid     = dgvBid.SelectedItem as Bid;
            Binding binding = new Binding();

            if (bid == null)
            {
                binding.Source = null;
            }
            else
            {
                List <Buyer> buyerList = new List <Buyer>();
                Buyer        buyer     = BuyerViewModel.instance().getById(bid.Id_buyer);
                if (buyer != null)
                {
                    buyerList.Add(buyer);
                    binding.Source = buyerList;
                }
                else
                {
                    binding.Source = null;
                }
            }
            dgvBuyer.SetBinding(DataGrid.ItemsSourceProperty, binding);
        }
Example #13
0
        public BuyerViewModel MapToViewModel(Buyer buyer)
        {
            BuyerViewModel buyerVM = new BuyerViewModel();

            buyerVM.Id                 = buyer.Id;
            buyerVM.UId                = buyer.UId;
            buyerVM._IsDeleted         = buyer._IsDeleted;
            buyerVM.Active             = buyer.Active;
            buyerVM._CreatedUtc        = buyer._CreatedUtc;
            buyerVM._CreatedBy         = buyer._CreatedBy;
            buyerVM._CreatedAgent      = buyer._CreatedAgent;
            buyerVM._LastModifiedUtc   = buyer._LastModifiedUtc;
            buyerVM._LastModifiedBy    = buyer._LastModifiedBy;
            buyerVM._LastModifiedAgent = buyer._LastModifiedAgent;
            buyerVM.Code               = buyer.Code;
            buyerVM.Name               = buyer.Name;
            buyerVM.Address            = buyer.Address;
            buyerVM.City               = buyer.City;
            buyerVM.Country            = buyer.Country;
            buyerVM.Contact            = buyer.Contact;
            buyerVM.Tempo              = buyer.Tempo;
            buyerVM.Type               = buyer.Type;
            buyerVM.NPWP               = buyer.NPWP;

            return(buyerVM);
        }
Example #14
0
        public Buyer MapToModel(BuyerViewModel buyerVM)
        {
            Buyer buyer = new Buyer();

            buyer.Id                 = buyerVM.Id;
            buyer.UId                = buyerVM.UId;
            buyer._IsDeleted         = buyerVM._IsDeleted;
            buyer.Active             = buyerVM.Active;
            buyer._CreatedUtc        = buyerVM._CreatedUtc;
            buyer._CreatedBy         = buyerVM._CreatedBy;
            buyer._CreatedAgent      = buyerVM._CreatedAgent;
            buyer._LastModifiedUtc   = buyerVM._LastModifiedUtc;
            buyer._LastModifiedBy    = buyerVM._LastModifiedBy;
            buyer._LastModifiedAgent = buyerVM._LastModifiedAgent;
            buyer.Code               = buyerVM.Code;
            buyer.Name               = buyerVM.Name;
            buyer.Address            = buyerVM.Address;
            buyer.City               = buyerVM.City;
            buyer.Country            = buyerVM.Country;
            buyer.Contact            = buyerVM.Contact;
            buyer.Tempo              = !Equals(buyerVM.Tempo, null) ? Convert.ToInt32(buyerVM.Tempo) : null; /* Check Null */
            buyer.Type               = buyerVM.Type;
            buyer.NPWP               = buyerVM.NPWP;

            return(buyer);
        }
Example #15
0
        public async Task <IActionResult> Edit(int id, [Bind("BuyerID,Name,Email,Nickname,CreatedDate,LastUpdatedDate,IsActive")] BuyerViewModel buyer)
        {
            if (id != buyer.BuyerID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri(BaseUrl);
                        var responseTask = await client.PutAsJsonAsync($"Buyers/{id}", buyer);

                        return(RedirectToAction(nameof(Index)));
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(buyer));
        }
Example #16
0
        private bool loadModels()
        {
            CRMSettingViewModel.instance();

            ComplectationItemViewModel.instance();

            EquipmentViewModel.instance();
            ModificationViewModel.instance();
            SellerViewModel.instance();
            BuyerViewModel.instance();
            BidStatusViewModel.instance();
            PaymentStatusViewModel.instance();
            MessageTemplatesViewModel.instance();

            RoleViewModel.instance();
            ManagerViewModel.instance();

            BidViewModel.instance();



            //EquipmentBidViewModel.instance();
            //ComplectationViewModel.instance();

            //ComplectationItemViewModel.instance();

            return(true);
        }
Example #17
0
        //Пятая строка (дата отгрузки и покупатель)
        private bool createShipmentDateRow()
        {
            Buyer buyer = BuyerViewModel.instance().getById(bid.Id_buyer);

            if (buyer == null)
            {
                return(false);
            }
            ReportRow row = new ReportRow();

            row.Cells.Add(new ReportCell("Дата отгрузки")
            {
                Height    = 16.50,
                TextStyle = new List <TextStyle>()
                {
                    TextStyle.Bold
                },
                VerticalAlignment = VerticalAlignment.Bottom
            });
            AddEmptyCell(row, 2);
            string shipmentDate = "";

            if (bid.Planned_shipment_date != null)
            {
                shipmentDate = ((DateTime)bid.Planned_shipment_date).ToString("dd.MM.yyyy");
            }
            row.Cells.Add(new ReportCell(shipmentDate)
            {
                ColumnSpan  = 4,
                BorderColor = System.Drawing.Color.Black
            });
            AddEmptyCell(row, 3);
            row.Cells.Add(new ReportCell()
            {
                VerticalAlignment = VerticalAlignment.Bottom
            });
            row.Cells.Add(new ReportCell("Покупатель")
            {
                TextStyle = new List <TextStyle>()
                {
                    TextStyle.Bold
                },
                VerticalAlignment = VerticalAlignment.Bottom
            });
            AddEmptyCell(row, 2);
            row.Cells.Add(new ReportCell(buyer.Name)
            {
                ColumnSpan  = 4,
                BorderColor = Color.Black
            });
            AddEmptyCell(row, 3);
            row.Cells.Add(new ReportCell()
            {
                VerticalAlignment = VerticalAlignment.Bottom
            });
            Rows.Add(row);

            return(true);
        }
Example #18
0
        // GET: Buyer
        public ActionResult Index()
        {
            BuyerViewModel svm = new BuyerViewModel();

            svm.BuyerId = Utils.GetBuyer();
            svm.GetProperties();
            return(View(svm));
        }
Example #19
0
        public Buyer MapToModel(BuyerViewModel viewModel)
        {
            Buyer model = new Buyer();

            PropertyCopier <BuyerViewModel, Buyer> .Copy(viewModel, model);

            return(model);
        }
Example #20
0
        public BuyerViewModel MapToViewModel(Buyer model)
        {
            BuyerViewModel viewModel = new BuyerViewModel();

            PropertyCopier <Buyer, BuyerViewModel> .Copy(model, viewModel);

            return(viewModel);
        }
 public SelectBuyerPeriodWindow()
 {
     InitializeComponent();
     DataContext = new
     {
         BuyerCollection = BuyerViewModel.instance().Collection
     };
 }
        //Клик по кнопке печати бланков
        void BtnPrintBlank_Click(object sender, RoutedEventArgs e)
        {
            Bid bid = dgvBid.SelectedItem as Bid;

            if (bid == null)
            {
                return;
            }

            Buyer buyer = BuyerViewModel.instance().getById(bid.Id_buyer);

            if (buyer == null)
            {
                return;
            }

            var openFolderDialog = new System.Windows.Forms.FolderBrowserDialog();

            if (iniFile.KeyExists("report_path") && System.IO.Directory.Exists(iniFile.Read("report_path")))
            {
                openFolderDialog.SelectedPath = iniFile.Read("report_path");
            }
            System.Windows.Forms.DialogResult result =
                openFolderDialog.ShowDialog(Classes.OpenDirectoryDialog.GetIWin32Window(this));

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                processControl.Visibility = Visibility.Visible;
                Task.Factory.StartNew(() => {
                    int reportCount = bid.EquipmentBidCollection.Count;
                    for (int i = 0; i < reportCount; i++)
                    {
                        Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Text = "Формирование бланков " + (i + 1).ToString() + " из " + reportCount.ToString(); }));
                        EquipmentBid equipmentBid = bid.EquipmentBidCollection[i];
                        string fileName           = "Бланк заявки №" + bid.Id.ToString() + "-" + equipmentBid.Id.ToString() + " " + bid.Account + " " + buyer.Name + ".xlsx";
                        Reports.BidBlank bidBlank = new StangradCRM.Reports.BidBlank(bid, equipmentBid);
                        bidBlank.FileName         = openFolderDialog.SelectedPath + "/" + Classes.ReplaceSpecialCharsFileName.Replace(fileName);
                        if (!bidBlank.Save())
                        {
                            MessageBox.Show(bidBlank.LastError);
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Visibility = Visibility.Hidden; }));
                            return;
                        }
                        equipmentBid.Is_blank_print = 1;
                        if (!equipmentBid.save())
                        {
                            MessageBox.Show("Не удалось установить статус 'Бланк заявки сформирован' для оборудования в заявке\n" + equipmentBid.LastError);
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Visibility = Visibility.Hidden; }));
                            return;
                        }
                    }
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { processControl.Visibility = Visibility.Hidden; }));
                    MessageBox.Show("Все бланки заявок сохранены в директорию '" + openFolderDialog.SelectedPath + "'");
                    iniFile.Write("report_path", openFolderDialog.SelectedPath);
                    System.Diagnostics.Process.Start(openFolderDialog.SelectedPath);
                });
            }
        }
Example #23
0
        /// <summary>
        ///     ctor().
        /// </summary>
        public BuyerView()
        {
            InitializeComponent();

            BindingContext = _viewModel = new BuyerViewModel();

            SfChart        chart          = new SfChart();
            DoughnutSeries doughnutSeries = new DoughnutSeries()
            {
                ItemsSource         = _viewModel.ChartData,
                XBindingPath        = "Name",
                YBindingPath        = "Value",
                DoughnutCoefficient = 0.7,
                ExplodeIndex        = 0
            };
            List <Color> colors = new List <Color>()
            {
                Color.FromHex("#82DA69"),
                Color.FromHex("#E47132"),
                Color.FromHex("#9EE5FC"),
            };

            doughnutSeries.ColorModel.Palette       = ChartColorPalette.Custom;
            doughnutSeries.ColorModel.CustomBrushes = colors;
            chart.WidthRequest  = 180;
            chart.HeightRequest = 180;
            //chart.BackgroundColor = Color.FromHex("#F3F3F3");
            chart.Series.Add(doughnutSeries);

            chart.Title.TextColor   = Color.FromHex("#cccccc");
            chart.HorizontalOptions = LayoutOptions.Center;
            chart.VerticalOptions   = LayoutOptions.Center;
            ChartGrid.Children.Add(chart);

            StackLayout MiddleStack = new StackLayout()
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor   = Color.White
            };
            Label MiddleText1 = new Label()
            {
                Text           = "23%",
                FontSize       = 20,
                FontAttributes = FontAttributes.Bold
            };
            Label MiddleText2 = new Label()
            {
                Text           = "mobile",
                FontSize       = 10,
                FontAttributes = FontAttributes.Bold
            };

            MiddleStack.Children.Add(MiddleText1);
            MiddleStack.Children.Add(MiddleText2);
            ChartGrid.Children.Add(MiddleStack);
        }
Example #24
0
        public ActionResult AddBuyer()
        {
            var viewModel = new BuyerViewModel()
            {
                IsActive = true
            };

            return(PartialView(viewModel));
        }
Example #25
0
        public ActionResult Create()
        {
            BuyerViewModel p = new BuyerViewModel();

            p.IsActive = true;
            p.Code     = new PersonService(_unitOfWork).GetMaxCode();
            PrepareViewBag();
            return(View("Create", p));
        }
Example #26
0
        public async Task Delete()
        {
            Buyer buyer = await DataUtil.GetTestDataAsync();

            BuyerViewModel VM       = Service.MapToViewModel(buyer);
            var            response = await this.Client.DeleteAsync(string.Concat(URI, "/", VM.Id));

            Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
        }
Example #27
0
        public async Task Update()
        {
            Buyer buyer = await DataUtil.GetTestDataAsync();

            BuyerViewModel VM       = Service.MapToViewModel(buyer);
            var            response = await this.Client.PutAsync(string.Concat(URI, "/", VM.Id), new StringContent(JsonConvert.SerializeObject(VM).ToString(), Encoding.UTF8, "application/json"));

            Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
        }
Example #28
0
        public void Validate_Email_NotValid()
        {
            BuyerViewModel viewModel = new BuyerViewModel()
            {
                email = "adepamungkasgmail.com",
            };
            var result = viewModel.Validate(null);

            Assert.True(result.Count() > 0);
        }
 void MiDataRefresh_Click(object sender, RoutedEventArgs e)
 {
     Classes.UpdateTask.StartSingle(Dispatcher,
                                    new Action(() => {
         BuyerViewModel.instance().reload();
         ComplectationItemViewModel.instance().reload();
         BidViewModel.instance().reload();
     }),
                                    new Action(() => { updateNotification.Visibility = Visibility.Visible; }),
                                    new Action(() => { updateNotification.Visibility = Visibility.Hidden; }));
 }
        private BuyerViewModel InitilCreateBulk()
        {
            BuyerViewModel objbuyer = new BuyerViewModel();

            //objbuyer.buyer = new BuyerModel();
            objbuyer.productInfo     = new BuyerProductModel();
            objbuyer.LstProducts     = new List <BuyerProductModel>();
            objbuyer.Installments    = new BuyerInstallmentModel();
            objbuyer.LstInstallments = new List <BuyerInstallmentModel>();
            return(objbuyer);
        }