Exemplo n.º 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");
 }
Exemplo n.º 2
0
 public void UpdateCirlce(CirlceBll c)//+
 {
     if (_ds.UpdateCircle(new Cirlce(null, c.Id, c.Name, c.Radius)) == 0)
     {
         throw new DataNotFoundException(string.Format("Cannot find circle with id ={0}", c.Id));
     }
 }
Exemplo n.º 3
0
        public ActionResult CircleEdit(int?id) //+
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            try
            {
                CirlceBll c = _figuresService.GetCirlceById(id.Value);
                CircleCreatingAndEditingView cv = new CircleCreatingAndEditingView()
                {
                    Id = c.Id, Name = c.Name, Radius = c.Radius.ToString()
                };
                return(View(cv));
            }
            catch (DataNotFoundException ex)
            {
                return(RedirectToAction("DataNotFound", "Error", new { message = ex.Message }));
            }
            catch (Exception ex)
            {
                return(HttpNotFound(ex.Message));
            }

            /*
             * ActionResult CircleEdit(PagingInfoView pagingInfoView, int? id)//+
             * pass values from Html.BeginForm into controller
             * @Html.HiddenFor(model => pagingInfoView.TotalItems)
             * @Html.HiddenFor(model => pagingInfoView.CurrentPage)
             * @Html.HiddenFor(model => pagingInfoView.ItemsPerPage)
             *
             * @Html.HiddenFor(model => id)
             */
        }
Exemplo n.º 4
0
 public void CreateCirlce(CirlceBll c)
 {
     _ds.CreateCircle(new Cirlce(null, 0, c.Name, c.Radius));
 }