public ActionResult Create(Client client)
        {
            if (ModelState.IsValid)
            {

                try
                {
                    // Your code...
                    // Could also be before try if you know the exception occurs in SaveChanges
                db.Client.Add(client);
                    db.SaveChanges();
                return RedirectToAction("Index");

                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }

            }

            return View(client);
        }
 public ClientsViewModel(RadoService.DAl.Client client)
 {
     this.age       = client.age;
     this.firstName = client.firstName;
     this.lastName  = client.lastName;
     this.address   = client.address;
     this.phone     = client.phone;
     this.defect    = client.defect;
     this.price     = client.price;
     this.date      = client.date;
     this.deadLine  = client.deadLine;
 }
 public ActionResult Edit(Client client)
 {
     if (ModelState.IsValid)
     {
         db.Entry(client).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(client);
 }