예제 #1
0
 public static TemplateEntity ToModel(this TemplateEntityViewModel templateEntity)
 {
     return(new TemplateEntity
     {
         Id = templateEntity.Id,
         Name = templateEntity.Name,
         DateTime = templateEntity.DateTime,
         IsActive = templateEntity.IsActive,
         CountryId = templateEntity.CountryId
     });
 }
예제 #2
0
        public async Task <ActionResult> AddOrUpdate(TemplateEntityViewModel templateEntity)
        {
            if (ModelState.IsValid)
            {
                await _templateService.AddOrUpdateAsync(templateEntity);

                return(RedirectToAction("Index"));
            }
            templateEntity.CountriesDdl = await _templateService.GetCountriesDropdownAsync();

            return(View(templateEntity));
        }
예제 #3
0
        public async Task <ActionResult> AddOrUpdate(int id = 0)
        {
            var model = new TemplateEntityViewModel();

            if (id != 0)
            {
                model = await _templateService.GetByIdAsync(id);

                return(View("AddOrUpdate", model));
            }

            model.CountriesDdl = await _templateService.GetCountriesDropdownAsync();

            return(View(model));
        }
예제 #4
0
        public async Task <bool> AddOrUpdateAsync(TemplateEntityViewModel template)
        {
            try
            {
                await _unitOfWork.Repository <TemplateEntity>().AddOrUpdateAsync(template.ToModel());

                await _unitOfWork.Commit();

                return(true);
            }
            catch
            {
                return(false);
            }
        }