示例#1
0
        public ActionResult Create(int ID, string SearchText, int?LocationGroupID)
        {
            try
            {
                REF_LOCATION_TB location = _uow.Repository <REF_LOCATION_TB>().GetById(ID);

                LocationCreateGroupViewModel model = new LocationCreateGroupViewModel()
                {
                    ID = ID,
                    LocationDescription   = location.SZ_LABEL + " - " + location.SZ_DESCRIPTION,
                    LocationGroups        = (List <SelectListItem>)_locationRepo.GetLocationGroupsSelectListByLocationID(ID),
                    SelectedLocationGroup = 0,
                    SearchText            = SearchText
                };

                return(View(model));
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    ViewBag.Message = "Function: LocationController.Create_GET\n\nError: " + ex.Message;
                }
                else
                {
                    ViewBag.Message = "Function: LocationController.Create_GET\n\nError: " + (ex.Message + "\n\nInnerException: " + ex.InnerException.Message);
                };
                Session["ErrorMessage"] = ViewBag.Message;
                return(RedirectToAction("InternalServerError", "Error"));
            };
        }
示例#2
0
        public ActionResult Create(LocationCreateGroupViewModel Model, bool IsTest = false)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    REF_LOCATION_X_LOCATION_GROUP_TB record = new REF_LOCATION_X_LOCATION_GROUP_TB()
                    {
                        B_INACTIVE             = false,
                        DT_ENTERED             = DateTime.UtcNow,
                        DT_MODIFIED            = DateTime.UtcNow,
                        N_LOCATION_GROUP_SYSID = Model.SelectedLocationGroup,
                        N_LOCATION_SYSID       = Model.ID,
                        SZ_ENTERED_BY          = IsTest ? "Unit Test Case" : _modifiedBy,
                        SZ_MODIFIED_BY         = _modifiedBy
                    };

                    _uow.Repository <REF_LOCATION_X_LOCATION_GROUP_TB>().Add(record);
                    _uow.SaveChanges();

                    return(RedirectToAction("Details", new { ID = Model.ID, SearchText = Model.SearchText, LocationGroupID = Model.SelectedLocationGroup }));
                }

                Model.LocationGroups = (List <SelectListItem>)_locationRepo.GetLocationGroupsSelectListByLocationID(Model.ID);

                return(View(Model));
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    ViewBag.Message = "Function: LocationController.Create_POST\n\nError: " + ex.Message;
                }
                else
                {
                    ViewBag.Message = "Function: LocationController.Create_POST\n\nError: " + (ex.Message + "\n\nInnerException: " + ex.InnerException.Message);
                };
                Session["ErrorMessage"] = ViewBag.Message;
                return(RedirectToAction("InternalServerError", "Error"));
            };
        }