public IActionResult OnGet(int?id) { #region LostItem Object LostItemObj = new LostItemVM() { LostItem = new Models.LostItem() }; LostItemObj.LostItem = _unitOfWork.LostItem.GetFirstOrDefault(u => u.Id == id); if (LostItemObj == null) { return(NotFound()); } #endregion #region Owner Object OwnerObj = _unitOfWork.Owner.GetFirstOrDefault(u => u.Id == LostItemObj.LostItem.OwnerId); if (OwnerObj == null) { return(NotFound()); } #endregion #region Phone Number Formatting phoneNumber = String.Format("{0:(###) ###-####}", Convert.ToInt64(OwnerObj.PhoneNumber)); #endregion #region Date Formatting date = (LostItemObj.LostItem.Date); formattedDate = date.ToString("MM/dd/yyyy"); #endregion return(Page()); }
public IActionResult OnGet(int?id) { #region Owner Info if (User.FindFirstValue(ClaimTypes.NameIdentifier) != null) { OwnerId = User.FindFirstValue(ClaimTypes.NameIdentifier); //Grab the OwnerId from the Login to use as a hidden field. } #endregion #region LostItem Object LostItemObj = new LostItemVM() { LostItem = new Models.LostItem(), OwnerList = _unitOfWork.Owner.GetOwnerListForDropdown() }; LostItemObj.LostItem.Date = DateTime.Now; // Default a NEW Lost and Found Item's Date to the current DateTime. if (id != null) { LostItemObj.LostItem = _unitOfWork.LostItem.GetFirstOrDefault(u => u.Id == id); if (LostItemObj == null) { return(NotFound()); } } #endregion return(Page()); //Refreshes page onGet if there's no id passed in }
public IActionResult OnGet(int?id) { #region LostItem Object LostItemObj = new LostItemVM() { LostItem = new Models.LostItem(), OwnerList = _unitOfWork.Owner.GetOwnerListForDropdown() }; LostItemObj.LostItem.Date = DateTime.Now; // Default a NEW Lost and Found Item's Date to the current DateTime. if (id != null) { LostItemObj.LostItem = _unitOfWork.LostItem.GetFirstOrDefault(u => u.Id == id); if (LostItemObj == null) { return(NotFound()); } } #endregion return(Page()); //Refreshes page onGet if there's no id passed in }
public IActionResult OnGet(int?id) { #region LostItem Object // Create the View Model LostItemObj = new LostItemVM() { LostItem = new Models.LostItem() }; // Fill the View Model with the related information based on the Id of the Lost and Found Object LostItemObj.LostItem = _unitOfWork.LostItem.GetFirstOrDefault(u => u.Id == id); if (LostItemObj == null) { return(NotFound()); } #endregion #region Owner Object // Create the Owner Object to grab Information from the Owner Table used for display purposes. OwnerObj = _unitOfWork.Owner.GetFirstOrDefault(u => u.Id == LostItemObj.LostItem.OwnerId); if (OwnerObj == null) { return(NotFound()); } #endregion #region Phone Number Formatting phoneNumber = String.Format("{0:(###) ###-####}", Convert.ToInt64(OwnerObj.PhoneNumber)); //Format the PhoneNumber for display #endregion #region Date Formatting date = (LostItemObj.LostItem.Date); // Grab the date. formattedDate = date.ToString("MM/dd/yyyy"); // Format the date for display. #endregion return(Page()); }