Esempio n. 1
0
        public IActionResult Edit(LifterModel lifter, string id)
        {
            var lifterToCreate = _updateHelper.CopyNonNullItems(lifter, _repository.GetItemAsync(id).Result);
            var lifterToReturn = _repository.UpdateItemAsync(id, lifterToCreate).Result;

            return(RedirectToAction(nameof(Details), new { id = lifterToReturn.Id }));
        }
Esempio n. 2
0
        public void TestController()
        {
            var         repo       = new DocumentDBRepository <LifterModel>();
            var         helper     = new UpdateModel <LifterModel>();
            var         controller = new LifterController(repo, helper);
            LifterModel testLifter = new LifterModel
            {
                Age            = "19",
                Name           = "Dylan",
                Weight         = "185",
                LiftingNumbers = new LiftingNumbersModel
                {
                    Squat    = "385",
                    Bench    = "275",
                    Deadlift = "485"
                }
            };

            controller.CreateLifter(testLifter);
            var        model  = repo.CreateItemAsync(testLifter).Result;
            JsonResult result = (JsonResult)controller.GetLifter(model.Id);

            testLifter.Id = model.Id;
            JsonResult expected = new JsonResult(testLifter);

            Assert.AreEqual(result.ToString(), expected.ToString());
        }
Esempio n. 3
0
        public IActionResult CreateLifter([FromBody] LifterModel lifter)
        {
            if (lifter == null)
            {
                return(BadRequest());
            }
            var lifterToReturn = _repository.CreateItemAsync(lifter).Result;

            return(CreatedAtRoute("GetLifter", new { id = lifterToReturn.Id }, lifterToReturn));
        }
Esempio n. 4
0
        public IActionResult UpdateLifter([FromBody] LifterModel lifter, string id)
        {
            if (lifter == null)
            {
                return(BadRequest());
            }
            var lifterToCreate = _updateHelper.CopyNonNullItems(lifter, _repository.GetItemAsync(id).Result);

            if (lifterToCreate == null)
            {
                return(BadRequest());
            }
            var returnItem = _repository.UpdateItemAsync(id, lifterToCreate).Result;

            return(CreatedAtRoute("GetLifter", new { id = lifterToCreate.Id }, lifterToCreate));
        }
Esempio n. 5
0
        public IActionResult Create(LifterModel lifter)
        {
            LifterModel lifterToAdd = new LifterModel
            {
                Type           = "lifter",
                Name           = lifter.Name,
                Gender         = lifter.Gender,
                Age            = lifter.Age,
                Weight         = lifter.Weight,
                LiftingNumbers = new LiftingNumbersModel
                {
                    Squat    = lifter.LiftingNumbers.Squat,
                    Bench    = lifter.LiftingNumbers.Bench,
                    Deadlift = lifter.LiftingNumbers.Deadlift
                }
            };
            var lifterToReturn = _repository.CreateItemAsync(lifterToAdd).Result;

            return(RedirectToAction(nameof(Details), new { id = lifterToReturn.Id }));
        }
Esempio n. 6
0
 public WilksCalculator(LifterModel lifter)
 {
     _lifter = lifter;
 }