Пример #1
0
        /*
         * Developer: Hamza Haq
         * Date: 8-20-19
         * Action: update vendor product to database
         * Input: vendor products
         * output: result
         */
        public async Task <Boolean> Update(VendorProducts VendorToUpdate)
        {
            using (IDbConnection conn = Connection)
            {
                var result = await conn.UpdateAsync <VendorProducts>(VendorToUpdate);

                return(result);
            }
        }
Пример #2
0
        /*
         * Developer: Hamza Haq
         * Date: 8-20-19
         * Action: creating new vendor product to database
         * Input: vendor repo
         * output: result
         */
        public async Task <string> Create(VendorProducts NewVendorProduct)
        {
            using (IDbConnection conn = Connection)
            {
                var result = await conn.InsertAsync <VendorProducts>(NewVendorProduct);

                return(result.ToString());
            }
        }
Пример #3
0
        public string Post([FromBody] List <ProductVendorSettle> listProductVendorSettl)
        {
            try
            {
                string vendorNo = "";
                if (listProductVendorSettl.Count > 0)
                {
                    vendorNo = listProductVendorSettl[0].VendorNo;

                    List <VendorProducts> listVendorProducts = _db.VendorProducts.Where(x => x.VendorNo == vendorNo).ToList();
                    foreach (VendorProducts vendorProducts in listVendorProducts)
                    {
                        _db.VendorProducts.Remove(vendorProducts);
                    }

                    _db.SaveChanges();
                }
                else
                {
                    return("接收設定資料失敗!!");
                }

                foreach (ProductVendorSettle productVendorSettle in listProductVendorSettl)
                {
                    if (productVendorSettle.Manufacture.Equals("1"))
                    {
                        VendorProducts insertVendorProducts = new VendorProducts();
                        insertVendorProducts.VendorNo    = vendorNo;
                        insertVendorProducts.ProductNo   = productVendorSettle.ProductNo;
                        insertVendorProducts.ProductName = productVendorSettle.ProductName;
                        insertVendorProducts.spec        = productVendorSettle.Spec;


                        _db.VendorProducts.Add(insertVendorProducts);
                        _db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("success");
        }
Пример #4
0
        public async Task <string> vendorproductUpdatespecific([FromBody] string value)
        {
            string UpdateResult = "Success";

            try
            {
                VendorProducts VendorToUpdate = JsonConvert.DeserializeObject <VendorProducts>(value);
                VendorToUpdate.vendor_id  = VendorToUpdate.vendor_id;
                VendorToUpdate.product_id = VendorToUpdate.product_id;
                Dictionary <String, String> ValuesToUpdate = new Dictionary <string, string>();

                if (!string.IsNullOrEmpty(VendorToUpdate.vendor_color_code))
                {
                    ValuesToUpdate.Add("vendor_color_code", VendorToUpdate.vendor_color_code);
                }
                if (!string.IsNullOrEmpty(VendorToUpdate.vendor_color_name))
                {
                    ValuesToUpdate.Add("vendor_color_name", VendorToUpdate.vendor_product_code);
                }
                if (!string.IsNullOrEmpty(VendorToUpdate.vendor_product_code))
                {
                    ValuesToUpdate.Add("vendor_product_code", VendorToUpdate.vendor_product_code);
                }
                if (!string.IsNullOrEmpty(VendorToUpdate.vendor_product_name))
                {
                    ValuesToUpdate.Add("vendor_product_name", VendorToUpdate.vendor_product_name);
                }

                await _vendorproductRepository.UpdateSpecific(ValuesToUpdate, "product_id =" + VendorToUpdate.product_id + " and vendor_id=" + VendorToUpdate.vendor_id);
            }
            catch (Exception ex)
            {
                var logger = _loggerFactory.CreateLogger("internal_error_log");
                logger.LogInformation("Problem happened in updating new vendor with message" + ex.Message);
                UpdateResult = "Failed";
            }

            return(UpdateResult);
        }
Пример #5
0
        public async Task <string> PostAsyncVendorProduct([FromBody] string value)
        {
            string NewInsertionID = "0";

            try
            {
                VendorProducts newVendor  = JsonConvert.DeserializeObject <VendorProducts>(value);
                int            created_by = newVendor.created_by;
                NewInsertionID = await _vendorproductRepository.Create(newVendor);

                var eventModel = new EventModel(vendorEventTableName)
                {
                    EventName   = create_vendor_product,
                    EntityId    = newVendor.vendor_id,
                    RefrenceId  = Int32.Parse(NewInsertionID),
                    UserId      = created_by,
                    EventNoteId = Int32.Parse(NewInsertionID)
                };
                await _eventRepo.AddEventAsync(eventModel);

                var userEvent = new EventModel(userEventTableName)
                {
                    EventName   = create_vendor_product,
                    EntityId    = created_by,
                    RefrenceId  = Convert.ToInt32(NewInsertionID),
                    UserId      = created_by,
                    EventNoteId = Int32.Parse(NewInsertionID)
                };
                await _eventRepo.AddEventAsync(userEvent);
            }
            catch (Exception ex)
            {
                var logger = _loggerFactory.CreateLogger("internal_error_log");
                logger.LogInformation("Problem happened in making new vendor product with message" + ex.Message);
            }
            return(NewInsertionID);
        }