예제 #1
0
        public JsonResponse NewProduct(Product Product)
        {
            JsonResponse json = new JsonResponse();

            if (ModelState.IsValid)
            {
                if (!(Product == null))
                {
                    json.Data = db.Products.Add(Product);
                    db.SaveChanges();
                    return(json);
                }
            }
            json.Message = "Unsuccessful. Please see error message";
            json.Result  = "Failed";
            json.Error   = db.Products.Add(Product);
            return(json);
        }
예제 #2
0
        public JsonResponse NewCustomer(Customer customer)
        {
            JsonResponse json = new JsonResponse();

            if (ModelState.IsValid)
            {
                if (!(customer == null))
                {
                    json.Data = db.Customers.Add(customer);
                    db.SaveChanges();
                    return(json);
                }
            }
            json.Message = "Unsuccessful. Please see error message";
            json.Result  = "Failed";
            json.Error   = db.Customers.Add(customer);
            return(json);
        }
예제 #3
0
        public JsonResponse NewEmployee(Employee Employee)
        {
            JsonResponse json = new JsonResponse();

            if (ModelState.IsValid)
            {
                if (!(Employee == null))
                {
                    json.Data = db.Employees.Add(Employee);
                    db.SaveChanges();
                    return(json);
                }
            }
            json.Message = "Unsuccessful. Please see error message";
            json.Result  = "Failed";
            json.Error   = db.Employees.Add(Employee);
            return(json);
        }