Пример #1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            var model = new PropertyAdvisor();

            TryUpdateModel(model, collection);
            if (!ModelState.IsValid)
            {
                FlashError("数据验证未通过,请检查是否存在为空的必填项");
                return(View(model));
            }
            model.UpdatedBy = "SYSTEM";
            model.UpdatedAt = DateTime.Now;

            var service = new PropertyAdvisorAccountService();
            var r1      = service.Remove(model.No, model.ProjectNo);

            if (r1.HasError)
            {
                FlashMessage(r1);
                return(View(model));
            }
            var r2 = service.Create(model.Name, model.MobileNo, model.Title.Equals("案场经理"), model.ProjectNo);

            if (r2.HasError)
            {
                FlashMessage(r2);
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult Delete(FormCollection collection, long[] ids)
        {
            if (ids.IsNullOrEmpty())
            {
                FlashWarn("请选择一条数据");
                return(View());
            }
            var list = _service.GetByIds(ids);

            try
            {
                var service = new PropertyAdvisorAccountService();
                foreach (var advisor in list)
                {
                    var r1 = service.Remove(advisor.No, advisor.ProjectNo);
                    if (r1.HasError)
                    {
                        FlashMessage(r1);
                        return(View(list));
                    }
                }
                FlashSuccess("删除成功");
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                FlashError("删除失败");
                return(View(list));
            }
        }