Exemple #1
0
 public IActionResult OnGet(int?id)
 {
     FoodTypeObj = new Models.FoodType();
     if (id != null)
     {
         FoodTypeObj = _unitOfWork.FoodType.GetFirstOrDefualt(u => u.Id == id);
         if (FoodTypeObj == null)
         {
             return(NotFound());
         }
     }
     return(Page());
 }
 public IActionResult OnGet(int?id)
 {
     FoodTypeObj = new Models.FoodType();
     if (id != null)
     {
         var FoodTypeObj = dbContext.FoodType.GetFirstOrDefault(item => item.Id == id);
         if (FoodTypeObj == null)
         {
             return(NotFound());
         }
     }
     return(Page());
 }
Exemple #3
0
 public IActionResult OnGet(int?id)
 {
     FoodTypeObj = new();
     if (id != null)
     {
         FoodTypeObj = _unitOfWork.FoodType.GetFirstOrDefault(c => c.Id == id.Value);
         if (FoodTypeObj == null)
         {
             return(NotFound());
         }
     }
     return(Page());
 }
 public IActionResult OnGet(int?id)
 {
     FoodType = new Models.FoodType();
     if (id != null)
     {
         FoodType = _unitOfWork.FoodTypeRepository.GetFirstOrDefault(f => f.ID == id.GetValueOrDefault());
         if (FoodType == null)
         {
             NotFound();
         }
     }
     return(Page());
 }
Exemple #5
0
        public async Task <IActionResult> OnGet(int?id)
        {
            FoodType = new Models.FoodType();
            if (id is not null)
            {
                FoodType = await _unitOfWork.FoodTypeRepository.GetFirstOrDefaultAsync(x => x.Id == id);

                if (FoodType is null)
                {
                    return(NotFound());
                }
            }

            return(Page());
        }
Exemple #6
0
        public IActionResult OnGet(int?id)
        {
            FoodTypeObj = new Models.FoodType();

            //If has id its a edit request
            if (id != null)
            {
                FoodTypeObj = _unitOfWork.FoodType.GetFirstOrDefault(c => c.Id == id);
                if (FoodTypeObj == null)
                {
                    return(NotFound());
                }
            }

            return(Page());
        }
 public IActionResult OnGet(int?id)
 {
     if (id.HasValue)
     {
         FoodType = _unitOfWork.FoodType.GetFirstOrDefault(u => u.Id == id);
         if (FoodType == null)
         {
             return(NotFound());
         }
     }
     else
     {
         FoodType = new Models.FoodType();
     }
     return(Page());
 }
Exemple #8
0
        public IActionResult OnPost(Models.FoodType FoodTypeObj)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (FoodTypeObj.Id == 0)
            {
                _unitOfWork.FoodType.Add(FoodTypeObj);
            }

            _unitOfWork.FoodType.Update(FoodTypeObj);
            _unitOfWork.Save();
            return(RedirectToPage("Index"));
        }
Exemple #9
0
        public IActionResult OnGet(int?id)
        {
            //initialize obj
            FoodTypeObj = new Models.FoodType();

            //check obj validdation
            if (id != null)
            {
                FoodTypeObj = _unitOfWork.FoodType.GetFirstOrDefault(f => f.Id == id);

                if (FoodTypeObj == null)
                {
                    return(NotFound());
                }
            }

            return(Page());
        }