Example #1
0
        public async Task <ResponseModel> UpdateProduct(int id, Lemontech.DataLayer.Models.Product model)
        {
            try
            {
                _context.Entry(model).State = EntityState.Modified;

                await _context.SaveChangesAsync();

                return(new ResponseModel
                {
                    Message = "Update Product Successful",
                    Status = "Success"
                });
            }
            catch (Exception)
            {
                return(new ResponseModel
                {
                    Code = 400,
                    Message = "Update Product Failed",
                    Status = "Failed"
                });
            }
        }
Example #2
0
        public async Task <ResponseModel> CreateProduct(Lemontech.DataLayer.Models.Product model)
        {
            try
            {
                _context.Product.Add(model);

                await _context.SaveChangesAsync();

                return(new ResponseModel
                {
                    Message = "Create Product Successful",
                    Status = "Success"
                });
            }
            catch (Exception)
            {
                return(new ResponseModel
                {
                    Code = 400,
                    Message = "Create Product Failed",
                    Status = "Failed"
                });
            }
        }