Esempio n. 1
0
		public async Task<IActionResult> EditService(EditServiceViewModel model)
		{
			if ((model.Service?.Id ?? 0) != 0)
			{
				using (var repo = new ServiceRepository())
				{
					await repo.UpdateAsync(model.Service);
					return View(model);
				}
			}

			if (!string.IsNullOrWhiteSpace(model.Service?.Name))
			{
				using (var repo = new ServiceRepository())
				{
					await repo.AddAsync(model.Service);
					return View(model);
				}
			}

			return View(model);
		}
Esempio n. 2
0
        public async Task <IActionResult> EditService(EditServiceViewModel model)
        {
            if ((model.Service?.Id ?? 0) != 0)
            {
                using (var repo = new ServiceRepository())
                {
                    await repo.UpdateAsync(model.Service);

                    return(View(model));
                }
            }

            if (!string.IsNullOrWhiteSpace(model.Service?.Name))
            {
                using (var repo = new ServiceRepository())
                {
                    await repo.AddAsync(model.Service);

                    return(View(model));
                }
            }

            return(View(model));
        }