Exemplo n.º 1
0
 public ActionResult SquareCreate(SquareCreatingAndEditingView s)//+
 {
     if (ModelState.IsValid)
     //Range validation where value is with comma and not with dot
     //https://laracasts.com/discuss/channels/general-discussion/validate-numeric-with-both-comma-and-dot-nottation?page=1
     {
         try
         {
             _figuresService.CreateSquare(new SquareBll(null, 0, s.Name, float.Parse(s.Side)));
             return(RedirectToAction("Squares"));
         }
         catch (Exception ex)
         {
             return(HttpNotFound(ex.Message));
         }
     }
     return(View(s));
 }
Exemplo n.º 2
0
 public ActionResult SquareEdit(int?id) //+
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     try
     {
         SquareBll s = _figuresService.GetSquareById(id.Value);
         SquareCreatingAndEditingView cv = new SquareCreatingAndEditingView()
         {
             Id = s.Id, Name = s.Name, Side = s.Side.ToString()
         };
         return(View(cv));
     }
     catch (DataNotFoundException ex)
     {
         return(RedirectToAction("DataNotFound", "Error", new { message = ex.Message }));
     }
     catch (Exception ex)
     {
         return(HttpNotFound(ex.Message));
     }
 }