Beispiel #1
0
 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");
 }
Beispiel #2
0
 public void UpdateSquare(SquareBll s)//+
 {
     if (_ds.UpdateSquare(new Square(null, s.Id, s.Name, s.Side)) == 0)
     {
         throw new DataNotFoundException(string.Format("Cannot find square with id ={0}", s.Id));
     }
 }
Beispiel #3
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));
     }
 }
Beispiel #4
0
 public void CreateSquare(SquareBll s)
 {
     _ds.CreateSquare(new Square(null, 0, s.Name, s.Side));
 }