Ejemplo n.º 1
0
 public ActionResult Index(Order cModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             AddOrder.InsertOrder(cModel);
             string msg = "Record has been saved Successfully!!";
             return(RedirectToAction("Index", new { Msg = msg }));
         }
         else
         {
             //ModelState.AddModelError("", "The Password and Confirm Password do not match.");
             return(View(cModel));
         }
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                               eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                   ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
     return(View());
 }
Ejemplo n.º 2
0
 public IHttpActionResult OrderProcess(Order cModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (UnitTestEntities ctx = new UnitTestEntities())
             {
                 AddOrder.InsertOrder(cModel);
             }
             ObjectFactory.ObjResponse.ResponseMessage = "Save Successfully";
             ObjectFactory.ObjResponse.ResponseData    = cModel;
             ObjectFactory.ObjResponse.ResponseStatus  = true;
             return(Ok(ObjectFactory.ObjResponse));
         }
         ObjectFactory.ObjResponse.ResponseMessage = "API Call Fields are required";
         ObjectFactory.ObjResponse.ResponseData    = "";
         ObjectFactory.ObjResponse.ResponseStatus  = false;
     }
     catch (Exception ex)
     {
         ObjectFactory.ObjResponse.ResponseMessage = ex.ToString();
         ObjectFactory.ObjResponse.ResponseData    = "";
         ObjectFactory.ObjResponse.ResponseStatus  = false;
     }
     return(Ok(ObjectFactory.ObjResponse));
 }