示例#1
0
        public ActionResult Create(CustomerDetali customer)
        {
            if (ModelState.IsValid)
            {
                CustomerDetali detali = new CustomerDetali();

                bool detalinew = informationDetailsEntities.CustomerDetalis.Any(x => x.CustomerName == customer.CustomerName);
                if (detalinew)
                {
                    //ViewBag.CustomerName = "CustomerName is allrady in database";
                    ModelState.AddModelError("CustomerName", "CustomerName is allrady in database");
                }

                else
                {
                    detali.CustomerName    = customer.CustomerName;
                    detali.Email           = customer.Email;
                    detali.Phone           = customer.Phone;
                    detali.CustomerAddress = customer.CustomerAddress;
                    detali.City            = customer.City;
                    detali.images          = customer.images;
                    informationDetailsEntities.CustomerDetalis.Add(detali);
                    informationDetailsEntities.SaveChanges();
                    return(RedirectToAction("GetDetails"));
                }
            }
            return(View());
        }
示例#2
0
        public ActionResult Delete(CustomerDetali customer)
        {
            CustomerDetali emp = informationDetailsEntities.CustomerDetalis.Where(val => val.Id == customer.Id).Single <CustomerDetali>();

            informationDetailsEntities.CustomerDetalis.Remove(emp);
            informationDetailsEntities.SaveChanges();
            return(RedirectToAction("GetDetails"));
        }
示例#3
0
        public ActionResult Edit(int?id)
        {
            //CustomerDetali customer = new CustomerDetali();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerDetali customerDetali = informationDetailsEntities.CustomerDetalis.Find(id);

            if (customerDetali == null)
            {
                return(HttpNotFound());
            }
            return(View(customerDetali));
        }
示例#4
0
        public ActionResult Details(int?id)
        {
            CustomerDetali detali = new CustomerDetali();

            detali = informationDetailsEntities.CustomerDetalis.Where(val => val.Id == id).ToList().Select(val => new CustomerDetali()
            {
                Id              = val.Id,
                CustomerName    = val.CustomerName,
                CustomerAddress = val.CustomerAddress,
                Email           = val.Email,
                Phone           = val.Phone,
                City            = val.City,
                images          = val.images
            }).SingleOrDefault();
            return(View(detali));
        }
示例#5
0
 public ActionResult Edit([Bind(Include = "Id,CustomerName,Email,City,CustomerAddress,Phone,images")] CustomerDetali customer)
 {
     if (ModelState.IsValid)
     {
         CustomerDetali updatedCustomer = (from c in informationDetailsEntities.CustomerDetalis
                                           where c.Id == customer.Id
                                           select c).FirstOrDefault();
         updatedCustomer.CustomerName    = customer.CustomerName;
         updatedCustomer.Email           = customer.Email;
         updatedCustomer.City            = customer.City;
         updatedCustomer.CustomerAddress = customer.CustomerAddress;
         updatedCustomer.Phone           = customer.Phone;
         updatedCustomer.images          = updatedCustomer.images;
         //informationDetailsEntities.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }