public async Task <IActionResult> Create(SupplierCreateViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var supplier = new SupplierCreateDTO()
                    {
                        Name    = model.Name,
                        Email   = model.Email,
                        Phone   = model.Phone,
                        Address = model.Address,
                    };

                    await _supplierService.Create(supplier).ConfigureAwait(true);

                    _toastNotification.AddSuccessToastMessage("Supplier Name: - " + model.Name);

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                _toastNotification.AddErrorToastMessage(ex.Message);
            }
            return(View(model));
        }
        public async Task <IActionResult> Create(SupplierCreateViewModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            var supplierId = await this
                             .suppliersService
                             .CreateAsync(inputModel.Name, inputModel.Country, inputModel.Address, inputModel.NewImage);

            if (supplierId == null)
            {
                this.TempData[Notifications.Error] = Notifications.SuplierAlreadyExists;
                return(this.View(inputModel));
            }

            this.TempData[Notifications.Key] = Notifications.SuccessfullyCreatedSupplier;
            return(this.RedirectToAction("Details", new { id = supplierId }));
        }
        public async Task <ActionResult> Create(SupplierCreateViewModel model)
        {
            try
            {
                var supplier = new SupplierCreateDTO()
                {
                    Name    = model.Name,
                    Email   = model.Email,
                    Phone   = model.Phone,
                    Address = model.Address,
                };

                await _supplierService.Create(supplier).ConfigureAwait(true);

                var Supplier = await _supplierRepo.GetByNumber(supplier.Phone) ?? throw new System.Exception("Supplier Not Found.");

                return(Ok(CreateReponseDto(Supplier)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IActionResult> Add([FromBody] SupplierCreateViewModel supplier)
        {
            var id = await _supplierCommandFunctionality.AddAsync(Mapper.Map <SupplierCreateCommand>(supplier));

            return(ResponseWithData(StatusCodes.Status201Created, id));
        }
        public IActionResult Create()
        {
            var viewModel = new SupplierCreateViewModel();

            return(this.View(viewModel));
        }