public ActionResult Edit(RecipientDetailsEditModel model)
        {
            ApplicationUser user      = currentUserProvider.Get();
            Recipient       recipient = this.recipientProfileService.GetByApplicationUserId(user.Id);

            if (ModelState.IsValid)
            {
                Mapper.Map <RecipientDetailsEditModel, Recipient>(model, recipient);
                Mapper.Map <AccountDetailsEditModel, ApplicationUser>(model.AccountDetailsEditModel, recipient.ApplicationUser);

                var selectedCategories = model.FoodCategories.Where(c => c.IsChecked);
                recipient.FoodCategories.Clear();
                foreach (var categoryModel in selectedCategories)
                {
                    var category = this.foodCategoryService.GetById(categoryModel.Id);
                    recipient.FoodCategories.Add(category);
                }

                this.recipientProfileService.Update(recipient);

                return(RedirectToAction("Details", "Profile", new { area = "Recipients" }));
            }

            model.Cities         = this.GetCities();
            model.RecipientTypes = new SelectList(this.recipientTypeService.GetAll(), "Id", "Name");
            model.FoodCategories = this.GetFoodCategories(recipient);

            return(View(model));
        }
        public ActionResult Edit()
        {
            ApplicationUser user      = currentUserProvider.Get();
            Recipient       recipient = this.recipientProfileService.GetByApplicationUserId(user.Id);

            if (recipient == null)
            {
                return(HttpNotFound());
            }

            RecipientDetailsEditModel model = Mapper.Map <Recipient, RecipientDetailsEditModel>(recipient);

            model.AccountDetailsEditModel = Mapper.Map <ApplicationUser, AccountDetailsEditModel>(recipient.ApplicationUser);
            model.Cities         = this.GetCities();
            model.RecipientTypes = new SelectList(this.recipientTypeService.GetAll(), "Id", "Name");
            model.FoodCategories = this.GetFoodCategories(recipient);

            return(View(model));
        }
        public ActionResult Edit(RecipientDetailsEditModel model)
        {
            //ApplicationUser user = currentUserProvider.Get();
            Recipient recipient = this.recipientProfileService.GetById(model.Id);

            if (ModelState.IsValid)
            {
                Mapper.Map <RecipientDetailsEditModel, Recipient>(model, recipient);
                Mapper.Map <AccountDetailsEditModel, ApplicationUser>(model.AccountDetailsEditModel, recipient.ApplicationUser);

                this.recipientProfileService.Update(recipient);

                this.Flash("Recipient profile is updated", FlashEnum.Success);

                return(RedirectToAction("Index", "Recipients"));
            }

            model.Cities         = this.GetCities();
            model.RecipientTypes = this.GetRecipientTypes();

            return(View(model));
        }
        public ActionResult Edit(string username)
        {
            if (username == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Recipient recipient = this.recipientProfileService.GetByUserName(username);

            if (recipient == null)
            {
                return(HttpNotFound());
            }

            RecipientDetailsEditModel model = Mapper.Map <Recipient, RecipientDetailsEditModel>(recipient);

            model.AccountDetailsEditModel = Mapper.Map <ApplicationUser, AccountDetailsEditModel>(recipient.ApplicationUser);
            model.Cities         = this.GetCities();
            model.RecipientTypes = this.GetRecipientTypes();

            return(View(model));
        }