public static FigureView Create(FigureBll f) { if (f is CirlceBll) { CirlceBll c = (CirlceBll)f; return(new CirlceView() { IdInStore = c.IdInStore, Id = c.Id, Name = f.Name, Radius = c.Radius, Area = c.GetArea() }); } if (f is SquareBll) { SquareBll s = (SquareBll)f; return(new SquareView() { IdInStore = s.IdInStore, Id = s.Id, Name = f.Name, Side = s.Side, Area = s.GetArea() }); } if (f is RectangleBll) { RectangleBll r = (RectangleBll)f; return(new RectangleView() { IdInStore = r.IdInStore, Id = r.Id, Name = f.Name, Width = r.Width, Height = r.Height, Area = r.GetArea() }); } throw new ArgumentException("There is no such Figure"); }
public void UpdateRectangle(RectangleBll r)//+ { if (_ds.UpdateRectangle(new Rectangle(null, r.Id, r.Name, r.Width, r.Height)) == 0) { throw new DataNotFoundException(string.Format("Cannot find rectangle with id ={0}", r.Id)); } }
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)); } }
public void CreateRectangle(RectangleBll r) { _ds.CreateRectangle(new Rectangle(null, 0, r.Name, r.Width, r.Height)); }