Ejemplo n.º 1
0
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                ModelState.AddModelError("", "参数验证失败.");
                return View();
            }
            var section = _sectionRepo.Get(s => s.Id == id.Value && s.Status != (int)DataStatus.Deleted)
                .Join(_storeRepo.GetAll(), o => o.StoreId, i => i.Id, (o, i) => new { S = o, Store = i })
                .Join(_brandRepo.GetAll(), o => o.S.BrandId, i => i.Id, (o, i) => new { S = o.S, Store = o.Store, B = i }).FirstOrDefault();
            var vo = new SectionViewModel().FromEntity<SectionViewModel>(section.S, p =>
            {
                p.Store = new StoreViewModel().FromEntity<StoreViewModel>(section.Store);
                p.Brand = new BrandViewModel().FromEntity<BrandViewModel>(section.B);
            });

            return View(vo);
        }
Ejemplo n.º 2
0
        public ActionResult Create(FormCollection formCollection, SectionViewModel vo)
        {
            if (!ModelState.IsValid)
            {
                return View(vo);
            }
            var entity = vo.ToEntity<SectionEntity>();
            entity.CreateUser = base.CurrentUser.CustomerId;
            entity.CreateDate = DateTime.Now;
            entity.UpdateDate = DateTime.Now;
            entity.UpdateUser = CurrentUser.CustomerId;
            entity.Status = (int)DataStatus.Normal;
            _sectionRepo.Insert(entity);

            return RedirectToAction("Edit", new { id = entity.Id });

        }
Ejemplo n.º 3
0
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                ModelState.AddModelError("", "参数验证失败.");
                return View();
            }

            var vo = new SectionViewModel().FromEntity<SectionViewModel>(_sectionRepo.Find(id.Value));
                   

            return View(vo);
        }
Ejemplo n.º 4
0
        public ActionResult Edit(FormCollection formCollection, SectionViewModel vo)
        {
            if (!ModelState.IsValid)
            {
                return View(vo);
            }
            var entity = _sectionRepo.Find(vo.Id);
            entity.Name = vo.Name;
            entity.Location = vo.Location;
            entity.StoreId = vo.StoreId;
            entity.BrandId = vo.BrandId;
            entity.ContactPerson = vo.ContactPerson;
            entity.ContactPhone = vo.ContactPhone;

            entity.UpdateDate = DateTime.Now;
            entity.UpdateUser = CurrentUser.CustomerId;

            _sectionRepo.Update(entity);

            return RedirectToAction("details", new { id = entity.Id });
        }