Esempio n. 1
0
        public virtual ActionResult Save(long profileTypeId, ProfileHeaderViewModel model)
        {
            if (ModelState.IsValid)
            {
                var profileHeader = profileHeaderService.Find(model.Id);

                if (profileHeader == null)
                {
                    throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", String.Empty));
                }

                if (profileHeaderService.Save(model.MapTo(profileHeader)))
                {
                    //save locale
                    ProfileHeaderLocale locale = profileHeaderLocaleService.GetLocale(profileHeader.Id, model.SelectedCulture);
                    locale = model.MapLocaleTo(locale ?? new ProfileHeaderLocale {
                        ProfileHeader = profileHeader
                    });

                    profileHeaderLocaleService.Save(locale);

                    Success(HttpContext.Translate("Messages.Success", String.Empty));
                    return(RedirectToAction(ProfilesMVC.ProfileElement.Show(profileTypeId)));
                }
            }
            else
            {
                Error(HttpContext.Translate("Messages.ValidationError", String.Empty));
            }

            return(View("Edit", model));
        }
        public virtual ActionResult New(long profileTypeId, ProfileHeaderViewModel profileHeader)
        {
            if (ModelState.IsValid)
            {
                var savedItem = profileHeader.MapTo(new ProfileHeader
                                                        {
                                                            ProfileType = new ProfileType { Id = profileTypeId }
                                                        });
                savedItem.OrderNumber = profileHeaderService.GetLastOrderNumber(profileTypeId);
                if (profileHeaderService.Save(savedItem))
                {
                    Success(HttpContext.Translate("Messages.Success", String.Empty));
                    return RedirectToAction(ProfilesMVC.ProfileElement.Show(profileTypeId));
                }
            }
            else
            {
                Error(HttpContext.Translate("Messages.ValidationError", String.Empty));

            }

            return View("New", profileHeader);
        }
Esempio n. 3
0
        public virtual ActionResult New(long profileTypeId, ProfileHeaderViewModel profileHeader)
        {
            if (ModelState.IsValid)
            {
                var savedItem = profileHeader.MapTo(new ProfileHeader
                {
                    ProfileType = new ProfileType {
                        Id = profileTypeId
                    }
                });
                savedItem.OrderNumber = profileHeaderService.GetLastOrderNumber(profileTypeId);
                if (profileHeaderService.Save(savedItem))
                {
                    Success(HttpContext.Translate("Messages.Success", String.Empty));
                    return(RedirectToAction(ProfilesMVC.ProfileElement.Show(profileTypeId)));
                }
            }
            else
            {
                Error(HttpContext.Translate("Messages.ValidationError", String.Empty));
            }

            return(View("New", profileHeader));
        }
        public virtual ActionResult Save(long profileTypeId, ProfileHeaderViewModel model)
        {
            if (ModelState.IsValid)
            {
                var profileHeader = profileHeaderService.Find(model.Id);

                if (profileHeader == null)
                {
                    throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", String.Empty));
                }

                if (profileHeaderService.Save(model.MapTo(profileHeader)))
                {
                    //save locale
                    ProfileHeaderLocale locale = profileHeaderLocaleService.GetLocale(profileHeader.Id, model.SelectedCulture);
                    locale = model.MapLocaleTo(locale ?? new ProfileHeaderLocale { ProfileHeader = profileHeader });

                    profileHeaderLocaleService.Save(locale);

                    Success(HttpContext.Translate("Messages.Success", String.Empty));
                    return RedirectToAction(ProfilesMVC.ProfileElement.Show(profileTypeId));
                }
            }
            else
            {
                Error(HttpContext.Translate("Messages.ValidationError", String.Empty));
            }

            return View("Edit", model);
        }