public ActionResult RectangleCreate(RectangleCreatingAndEditingView r)//+ { 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.CreateRectangle(new RectangleBll(null, 0, r.Name, float.Parse(r.Width), float.Parse(r.Height))); return(RedirectToAction("Rectangles")); } catch (Exception ex) { return(HttpNotFound(ex.Message)); } } return(View(r)); }
public ActionResult RectangleEdit(int?id) //+ { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { RectangleBll c = _figuresService.GetRectangleById(id.Value); RectangleCreatingAndEditingView cv = new RectangleCreatingAndEditingView() { Id = c.Id, Name = c.Name, Width = c.Width.ToString(), Height = c.Height.ToString() }; return(View(cv)); } catch (DataNotFoundException ex) { return(RedirectToAction("DataNotFound", "Error", new { message = ex.Message })); } catch (Exception ex) { return(HttpNotFound(ex.Message)); } }