public static CategoryViewModel DeleteCategory(int id)
        {
            CategoryViewModel model = new CategoryViewModel();

            try
            {
                using (SampleCodeEntities db = new SampleCodeEntities())
                {
                    Category CT = db.Categories.Where(x => x.Id == id).FirstOrDefault();
                    db.Categories.Remove(CT);
                    if (db.SaveChanges() > 0)
                    {
                        model.ErrorCode    = "success";
                        model.ErrorMessage = "Category deleted successfully.";
                    }
                    else
                    {
                        model.ErrorCode    = "Error";
                        model.ErrorMessage = "Error";
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            return(model);
        }
        public static CategoryViewModel AddCategory(CategoryViewModel model)
        {
            try
            {
                using (SampleCodeEntities db = new SampleCodeEntities())
                {
                    if (!IsCheckExistsCategory(model.objModel.Name, model.objModel.Type))
                    {
                        Category C = new Category
                        {
                            Name   = model.objModel.Name,
                            TypeId = model.objModel.TypeId
                        };

                        db.Categories.Add(C);
                        if (db.SaveChanges() > 0)
                        {
                            model.ErrorCode    = "Success";
                            model.ErrorMessage = "Category created successfully.";
                        }
                        else
                        {
                            model.ErrorCode    = "Error";
                            model.ErrorMessage = "Name and Type already Exists!";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
                model.ErrorCode    = "Error";
                model.ErrorMessage = ex.Message;
            }
            return(model);
        }
        public ActionResult Update(CustomerViewModel model)
        {
            // CustomerViewModel model = new CustomerViewModel();
            using (SampleCodeEntities db = new SampleCodeEntities())
            {
                var custinfo = db.Customers.Where(x => x.Id == model.objModel.CustomerId).FirstOrDefault();
                custinfo.FirstName     = model.objModel.FirstName;
                custinfo.LastName      = model.objModel.LastName;
                custinfo.Emailaddress  = model.objModel.Emailaddress;
                custinfo.CompanyName   = model.objModel.CompanyName;
                custinfo.Country       = model.objModel.Country;
                custinfo.ContactNo     = model.objModel.ContactNo;
                custinfo.URL           = model.objModel.URL;
                custinfo.ContactPerson = model.objModel.ContactPerson;
                custinfo.Designation   = model.objModel.Designation;

                if (db.SaveChanges() > 0)
                {
                    return(RedirectToAction("CustomerList"));
                }
            }

            return(View(model));
        }