Ejemplo n.º 1
0
 public SupplierServiceTest()
 {
     _supplierService = new SupplierService(_supplierRepo.Object);
     _createDto       = new SupplierCreateDTO();
     _updateDto       = new SupplierUpdateDTO();
     _supplier        = new Supplier(full_name, address, email, phone);
 }
        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));
        }
Ejemplo n.º 3
0
        public async Task <SupplierDTO> PutAsync(SupplierCreateDTO supplier)
        {
            this.Logger.LogTrace($"{nameof(this.PutAsync)} called");

            var result = await this.SupplierCreateService.CreateAsync(this.Mapper.Map <SupplierUpdateModel>(supplier));

            return(this.Mapper.Map <SupplierDTO>(result));
        }
        public ActionResult AddNewSupplier(SupplierCreateDTO supplier)
        {
            var guid = supplierService.AddNewSupplier(supplier);

            string location = linkGenerator.GetPathByAction("GetSupplierByID", "Supplier", new { supplierID = guid });

            return(Created(location, guid));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Create(SupplierCreateDTO Supplier)
        {
            var result = await _SupplierService.Create(Supplier);

            return(CreatedAtAction(
                       "GetById",
                       new { id = result.SupplierId },
                       result));
        }
        public async Task Create(SupplierCreateDTO dto)
        {
            using var tx = TransactionScopeHelper.GetInstance();
            await ValidateSupplierNumber(dto.Phone);

            var supplier = new Supplier(dto.Name, dto.Address, dto.Email, dto.Phone);

            await _supplierRepo.InsertAsync(supplier).ConfigureAwait(false);

            tx.Complete();
        }
Ejemplo n.º 7
0
 public SupplierDTO Create(SupplierCreateDTO modelToCreate)
 {
     try
     {
         int newID        = UOW.SupplierRepo.Create(modelToCreate);
         var createResult = UOW.SupplierRepo.GetByID(newID);
         UOW.SaveChanges();
         return(createResult);
     }
     catch (Exception ex)
     {
         UOW.RollbackChanges();
         throw ex;
     }
 }
        public async Task <SupplierDTO> Create(SupplierCreateDTO model)
        {
            var entry = new Supplier
            {
                SupplierId    = model.SupplierId,
                UserId        = model.UserId,
                Qualification = model.Qualification
            };

            await _context.AddAsync(entry);

            await _context.SaveChangesAsync();

            return(_mapper.Map <SupplierDTO>(entry));
        }
Ejemplo n.º 9
0
        public int Create(SupplierCreateDTO entityToCreate)
        {
            try
            {
                string query = @"
                INSERT INTO Suppliers(SupplierCode, SupplierName, SupplierContactNumber, SupplierEmailAddress)
                VALUES (@SupplierCode, @SupplierName, @SupplierContactNumber,@SupplierEmailAddress)
                
                SELECT SCOPE_IDENTITY()";

                var queryParameters = new DynamicParameters();
                queryParameters.Add("@SupplierCode", entityToCreate.SupplierCode);
                queryParameters.Add("@SupplierName", entityToCreate.SupplierName);
                queryParameters.Add("@SupplierContactNumber", entityToCreate.SupplierContactNumber);
                queryParameters.Add("@SupplierEmailAddress", entityToCreate.SupplierEmailAddress);

                return(Connection.QueryFirst <int>(query, queryParameters, CurrentTrans));
            }
            catch (Exception ex)
            {
                throw SqlExceptionHandler.HandleSqlException(ex) ?? ex;
            }
        }
        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));
            }
        }
Ejemplo n.º 11
0
 public Guid AddNewSupplier(SupplierCreateDTO supplier)
 {
     return(supplierRepository.AddNewSupplier(mapper.Map <Supplier>(supplier)));
 }
Ejemplo n.º 12
0
 public ActionResult <SupplierDTO> Create([FromBody] SupplierCreateDTO userInput)
 {
     try { return(_supplierManager.Create(userInput)); }
     catch (BaseCustomException ex) { return(BadRequest(ex.Message)); }
 }
Ejemplo n.º 13
0
 public SupplierDTO Create(SupplierCreateDTO createModel)
 {
     return(_supplierService.Create(createModel));
 }