Example #1
0
        public ActionResult Delete(int id, BusinessLogicLayer.OwnedItemBLL collection)
        {
            try
            {
                // TODO: Add insert logic here
                using (ContextBLL ctx = new ContextBLL())
                {
                    OwnedItemBLL Mine = ctx.FindOwnedItemByID(id);
                    if (null == Mine)
                    {
                        return(View("ItemNotFound"));
                    }
                    if (!IsThisMine(ctx, Mine))
                    {
                        return(View("NotYourItem"));
                    }
                    ctx.DeleteOwnedItem(id);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception Ex)
            {
                ViewBag.Exception = Ex;
                return(View("Error"));
            }
        }
Example #2
0
        public int CreateOwnedItem(OwnedItemBLL OwnedItem)
        {
            int proposedReturnValue = -1;

            proposedReturnValue = _context.CreateOwnedItem(OwnedItem.OwnerID, OwnedItem.ItemDescription, OwnedItem.ItemPrice);
            return(proposedReturnValue);
        }
Example #3
0
        public ActionResult Edit(int id, BusinessLogicLayer.OwnedItemBLL collection)
        {
            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    OwnedItemBLL Mine = ctx.FindOwnedItemByID(collection.OwnedItemID);
                    if (null == Mine)
                    {
                        return(View("ItemNotFound"));
                    }
                    if (!IsThisMine(ctx, Mine))
                    {
                        return(View("NotYourItem"));
                    }

                    ctx.UpdateOwnedItem(collection);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception Ex)
            {
                ViewBag.Exception = Ex;
                return(View("Error"));
            }
        }
Example #4
0
        public OwnedItemBLL FindOwnedItemByID(int OwnedItemID)
        {
            OwnedItemBLL ProposedReturnValue = null;
            OwnedItemDAL DataLayerObject     = _context.FindOwnedItemByID(OwnedItemID);

            if (null != DataLayerObject)
            {
                ProposedReturnValue = new OwnedItemBLL(DataLayerObject);
            }
            return(ProposedReturnValue);
        }
Example #5
0
        public List <OwnedItemBLL> GetOwnedItemsRelatedToUser(int UserID, int skip, int take)
        {
            List <OwnedItemBLL> ProposedReturnValue    = new List <OwnedItemBLL>();
            List <OwnedItemDAL> ListOfDataLayerObjects = _context.GetOwnedItemsRelatedToUser(UserID, skip, take);

            foreach (OwnedItemDAL OwnedItem in ListOfDataLayerObjects)
            {
                OwnedItemBLL BusinessObject = new OwnedItemBLL(OwnedItem);
                ProposedReturnValue.Add(BusinessObject);
            }
            return(ProposedReturnValue);
        }
Example #6
0
        public ActionResult Create(BusinessLogicLayer.OwnedItemBLL collection)
        {
            try
            {
                // TODO: Add insert logic here
                using (ContextBLL ctx = new ContextBLL())
                {
                    ctx.CreateOwnedItem(collection);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception Ex)
            {
                ViewBag.Exception = Ex;
                return(View("Error"));
            }
        }
        public ActionResult Delete(int id, BusinessLogicLayer.OwnedItemBLL collection)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(collection));
                }
                // TODO: Add insert logic here
                using (ContextBLL ctx = new ContextBLL())
                {
                    ctx.DeleteOwnedItem(id);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception Ex)
            {
                ViewBag.Exception = Ex;
                return(View("Error"));
            }
        }
Example #8
0
 public void JustUpdateOwnedItem(OwnedItemBLL OwnedItem)
 {
     _context.UpdateOwnedItem(OwnedItem.OwnedItemID, OwnedItem.OwnerID, OwnedItem.ItemDescription, OwnedItem.ItemPrice);
 }
Example #9
0
 public void DeleteOwnedItem(OwnedItemBLL OwnedItem)
 {
     _context.DeleteOwnedItem(OwnedItem.OwnedItemID);
 }