示例#1
0
        public ActionResult Edit(Promouter model)
        {
            if (ModelState.IsValid)
            {
                var allAttributes = DataAccessLayer.GetAllAttributes();
                var editor = new PromouterEditor(allAttributes);
                var user = new PromouterUser();
                editor.Edit(model, user);
                DataAccessLayer.DbContext.SaveChanges();
                return Detail(model.UserId);
            }

            #if DEBUG
            throw new Exception("ModelState is invalid");
            #endif
            #if RELEASE
            return new EmptyResult();
            #endif
        }
        public ActionResult Edit(PromouterForm model, IEnumerable<HttpPostedFileBase> photos)
        {
            if (ModelState.IsValid)
            {
                model.NewPhotos = photos == null ? new List<HttpPostedFileBase>() : photos.Where(x => x != null);
                var user = DataAccessLayer.GetById<PromouterUser>(model.UserId);
                var editor = new PromouterEditor(DataAccessLayer);
                editor.Edit(model, user);
                DataAccessLayer.DbContext.SaveChanges();
                return new RedirectResult(string.Format("/Promouter/Edit/{0}", model.UserId));
            }

            #if DEBUG
            throw new Exception("ModelState is invalid");
            #else
            return new EmptyResult();
            #endif
        }