public Culture Map(CreateOrEditViewModel createOrEdit)
        {
            Culture culture = new Culture();

              if (createOrEdit.Id != null)
            culture = this.handler.Storage.GetRepository<ICultureRepository>().WithKey((int)createOrEdit.Id);

              culture.Code = createOrEdit.Code;
              culture.Name = createOrEdit.Name;
              return culture;
        }
        public Culture Map(CreateOrEditViewModel createOrEdit)
        {
            Culture culture = new Culture();

            if (createOrEdit.Id != null)
            {
                culture = this.handler.Storage.GetRepository <ICultureRepository>().WithKey((int)createOrEdit.Id);
            }

            culture.Code = createOrEdit.Code;
            culture.Name = createOrEdit.Name;
            return(culture);
        }
Example #3
0
        public Culture Map(CreateOrEditViewModel createOrEdit)
        {
            Culture culture = new Culture();

            if (createOrEdit.Id != null)
            {
                culture = this.RequestHandler.Storage.GetRepository <ICultureRepository>().WithKey((int)createOrEdit.Id);
            }

            culture.Code = createOrEdit.Code;
            culture.Name = createOrEdit.Name;
            culture.IsFrontendDefault = createOrEdit.IsFrontendDefault;
            culture.IsBackendDefault  = createOrEdit.IsBackendDefault;
            return(culture);
        }
        public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit)
        {
            if (this.ModelState.IsValid)
              {
            Culture culture = new CreateOrEditViewModelMapper(this).Map(createOrEdit);

            if (createOrEdit.Id == null)
              this.Storage.GetRepository<ICultureRepository>().Create(culture);

            else this.Storage.GetRepository<ICultureRepository>().Edit(culture);

            this.Storage.Save();
            return this.Redirect(this.Request.CombineUrl("/backend/cultures"));
              }

              return this.CreateRedirectToSelfResult();
        }