Ejemplo n.º 1
0
        public IHttpActionResult Create([FromBody] PurchaseDto[] dtoCol)
        {
            IHttpActionResult result;

            if (ModelState.IsValid && dtoCol != null)
            {
                using (logic)
                {
                    int[] boughtIdArray = new int[dtoCol.Length];
                    for (int i = 0; i < dtoCol.Length; i -= -1)
                    {
                        dtoCol[i].MadeOn = DateTime.Now;
                        boughtIdArray[i] = dtoCol[i].ThingId;
                    }

                    PurchaseDto[] retDtoCol = logic.CreateCollection(dtoCol);

                    using (var thingLogic = new ThingDaLogic(new TwnContext(), User.Identity.GetUserId()))
                    {
                        var thingDto = thingLogic.UpdateCollectionNotNeeded(boughtIdArray);
                    }

                    //createLinks(null);   //TODO

                    result = Ok(retDtoCol);  //TODO
                }
            }
            else
            {
                result = BadRequest(ModelState);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult All()
        {
            ThingDto[] thingArray;

            using (var logic = new ThingDaLogic(new TwnContext(), User.Identity.GetUserId()))
            {
                thingArray = logic.GetCollection();
            }

            ThingListViewModel viewModel = new ThingListViewModel()
            {
                Things = thingArray
            };

            return(View("List", viewModel));

            //return View("Index", new MultiViewModel() {
            //    HouseholdList = new HouseholdListViewModel() {
            //        Households = new List<HouseholdDto>() {
            //        new HouseholdDto() {
            //            HouseholdId = 191919,
            //            Name = "Crackhoussse",
            //            Address = new AddressDto() {
            //                Address1 = "rostrupsvej 7",
            //                Address2 = "",
            //                City = "Aalborg",
            //                Country = "DK",
            //                PostCode = "9000"
            //            }
            //        }
            //    }
            //    }
            //});
        }
Ejemplo n.º 3
0
        public ActionResult Update(int id)
        {
            ThingUpdateViewModel viewModel;

            using (var logic = new ThingDaLogic(new TwnContext(), User.Identity.GetUserId())) {
                viewModel = new ThingUpdateViewModel()
                {
                    Thing = logic.GetById(id)
                };
            };

            return(View("Update", viewModel));
        }
Ejemplo n.º 4
0
 public HouseholdDaLogic(TwnContext context, string userId)
 {
     this.userId     = userId;
     DatabaseContext = new TwnContext();
     thingDaLogic    = new ThingDaLogic(context, userId);
 }