Ejemplo n.º 1
0
        public TblProductPacking Register(TblProductPacking productpak)
        {
            try
            {
                using Repository <TblProductPacking> repo = new Repository <TblProductPacking>();
                if (productpak != null)
                {
                    //if(productpak.BarrelVerify==true)
                    //{

                    //}
                }
                repo.TblProductPacking.Add(productpak);
                if (repo.SaveChanges() > 0)
                {
                    return(productpak);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> RegisterProductpacking([FromBody] TblProductPacking productpacking)
        {
            var result = await Task.Run(() =>
            {
                APIResponse apiResponse = null;
                if (productpacking == null)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = "object can not be null"
                    }));
                }

                try
                {
                    if (new ProductpackingHelpers().GetList(productpacking.PackingCode).Count() > 0)
                    {
                        return(Ok(new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = $"productpacking Code {nameof(productpacking.PackingCode)} is already exists ,Please Use Different Code "
                        }));
                    }

                    var result = new ProductpackingHelpers().Register(productpacking);
                    if (result != null)
                    {
                        apiResponse = new APIResponse()
                        {
                            status = APIStatus.PASS.ToString(), response = result
                        };
                    }
                    else
                    {
                        apiResponse = new APIResponse()
                        {
                            status = APIStatus.FAIL.ToString(), response = "Registration Failed."
                        };
                    }

                    return(Ok(apiResponse));
                }
                catch (Exception ex)
                {
                    return(Ok(new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = ex.Message
                    }));
                }
            });

            return(result);
        }
Ejemplo n.º 3
0
        public TblProductPacking Update(TblProductPacking productpack)
        {
            try
            {
                using Repository <TblProductPacking> repo = new Repository <TblProductPacking>();
                repo.TblProductPacking.Update(productpack);
                if (repo.SaveChanges() > 0)
                {
                    return(productpack);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        public IActionResult UpdateProductpacking([FromBody] TblProductPacking productpack)
        {
            if (productpack == null)
            {
                return(Ok(new APIResponse {
                    status = APIStatus.FAIL.ToString(), response = $"{nameof(productpack)} cannot be null"
                }));
            }

            try
            {
                var         rs = new ProductpackingHelpers().Update(productpack);
                APIResponse apiResponse;
                if (rs != null)
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.PASS.ToString(), response = rs
                    };
                }
                else
                {
                    apiResponse = new APIResponse()
                    {
                        status = APIStatus.FAIL.ToString(), response = "Updation Failed."
                    };
                }
                return(Ok(apiResponse));
            }
            catch (Exception ex)
            {
                return(Ok(new APIResponse()
                {
                    status = APIStatus.FAIL.ToString(), response = ex.Message
                }));
            }
        }