Example #1
0
 public JsonResult DeleteTest(long id)
 {
     try
     {
         if (id > 0)
         {
             TestAthleteListViewModel model = new TestAthleteListViewModel();
             model.ID = id;
             using (var repository = new WebApiClientRepository <TestAthleteListViewModel>())
             {
                 var payload = repository.GlobalApiCallPost(model, "api/Test/DeleteTest");
                 if (payload != null)
                 {
                     return(Json(new { Success = true, Message = "Athlete is Deleted successfully" }));
                 }
                 return(Json(new { Success = true, Message = "Athlete is Deleted successfully" }));
             }
         }
         else
         {
             return(Json(new { Success = true, Message = "Something went wrong !! Please Try later." }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { Success = false, Message = "Athlete can not be deleted now!" }));
     }
 }
Example #2
0
        public ActionResult <PayloadResponse> EditTestAthlete([FromBody] TestAthleteListViewModel info)
        {
            PayloadResponse response = new PayloadResponse();

            response.RequestTime = DateTime.Now.ToString();

            TestAthlete athlete = _repo.TestAthleteRepository.GetAll().Where(x => x.ID == info.ID && !x.IsRemoved).FirstOrDefault();

            if (info == null && info.ID <= 0)
            {
                response.Message      = "Data did not send properly";
                response.Payload      = athlete;
                response.PayloadType  = "EditTestAthlete";
                response.ResponseTime = DateTime.Now.ToString();
                response.Success      = false;
                return(response);
            }
            athlete.TestValue       = info.Distance;
            athlete.UpdatedBy       = Convert.ToInt32(User.Identity.Name);
            athlete.UpdatedDate     = DateTime.Now;
            athlete.FitnessRatingID = _repo.TestCustomRepository.GetFitnessRatingID(info.Distance);
            _repo.TestAthleteRepository.Update(athlete);

            _repo.Save();

            response.Message      = "Athlete is successfully updated.";
            response.Payload      = null;
            response.PayloadType  = "EditTestAthlete";
            response.ResponseTime = DateTime.Now.ToString();
            response.Success      = true;
            return(response);
        }
Example #3
0
        public ActionResult EditAthleteTest(TestAthleteData data)
        {
            try
            {
                PayloadResponse          response = new PayloadResponse();
                TestAthleteListViewModel model    = new TestAthleteListViewModel();
                model.ID       = Convert.ToInt64(data.TestAthleteID);
                model.Distance = Convert.ToInt32(data.Distance);

                if (ModelState.IsValid)
                {
                    using (var repository = new WebApiClientRepository <PayloadResponse>())
                    {
                        response = repository.GlobalApiCallPost(model, "api/Test/EditTestAthlete");
                        if (response != null)
                        {
                            TempData["message_data_success"] = response.Message;
                            return(Ok(new { msg = response.Message }));
                        }
                    }
                }
                // TODO: Add insert logic here
                return(View());
            }
            catch
            {
                return(View());
            }
        }
Example #4
0
        public ActionResult DeleteAthlete([FromBody] TestAthleteListViewModel info)
        {
            TestAthlete athlete = _repo.TestAthleteRepository.GetAll().Where(x => x.ID == info.ID && !x.IsRemoved).FirstOrDefault();

            if (info == null && info.ID <= 0)
            {
                return(BadRequest());
            }
            athlete.IsRemoved = true;
            _repo.TestAthleteRepository.Update(athlete);
            _repo.Save();
            info.AthleteID = athlete.ID;
            info.ID        = athlete.ID;
            return(Ok(info));
        }
Example #5
0
        public ActionResult DeleteTest([FromBody] TestAthleteListViewModel info)
        {
            Test test = _repo.TestRepository.GetAll().Where(x => x.ID == info.ID && !x.IsRemoved).FirstOrDefault();

            if (info == null && info.ID <= 0)
            {
                return(BadRequest());
            }
            //test.IsRemoved = true;
            //_repo.TestRepository.Update(test);
            //_repo.Save();

            bool isDelete = _repo.TestCustomRepository.DeleteTest(info.ID, User.Identity.Name);

            info.AthleteID = test.ID;
            info.ID        = test.ID;
            return(Ok(info));
        }