Beispiel #1
0
        /// <summary>
        /// Edit Door Type
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> Edit(int id)
        {
            DoorTypeViewModel model = await generateAPIResponse.DoorTypeViewRepo.GetByID("doortype", id);

            if (model != null)
            {
                return(View("Create", model));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Save & Update Door Type Details with Post & Put Methods of the Web APIs.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        private async Task <IActionResult> SaveDoorTypeDetails(DoorTypeViewModel model, String action)
        {
            try
            {
                var response = false;

                // Call Post Method to Create New Door Type Details
                if (action.ToLower() == "create")
                {
                    response = await generateAPIResponse.DoorTypeViewRepo.Save("doortype", model);

                    ViewBag.Message = "Door Type record has been created successfully.";
                }
                // Call Put Method to Update Existing Door Type Details
                else
                {
                    response = await generateAPIResponse.DoorTypeViewRepo.Update("doortype/" + model.DoorTypeID, model);

                    ViewBag.Message = "Door Type record has been updated successfully.";
                }

                if (response)
                {
                    ViewBag.Class = "text-success";
                    return(await RedirectToIndex());
                }
                else
                {
                    ViewBag.Message = null;
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Something went wrong: " + ex.Message;
            }
            return(View("Create", model));
        }
Beispiel #3
0
 public async Task <IActionResult> Create(DoorTypeViewModel model)
 {
     return(await SaveDoorTypeDetails(model, "Create"));
 }
Beispiel #4
0
 public async Task <IActionResult> Edit(DoorTypeViewModel model)
 {
     return(await SaveDoorTypeDetails(model, "Edit"));
 }