Exemplo n.º 1
0
        public ActionResult Create(LrpVM lrpUser)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Lrp lrp = _mapper.Map <Lrp>(lrpUser);
                    _lrpUser.Insert(lrp);

                    User user = _mapper.Map <User>(lrpUser);
                    user.Name = lrpUser.fullName;
                    _user.Register(user, lrpUser.password);

                    ViewBag.Message = "Lrp User Created Successfully";
                    return(View());
                }
                else
                {
                    ModelState
                    .AddModelError(string.Empty, "Error");
                    return(View(lrpUser));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.ToString());
                return(View());
            }
        }
Exemplo n.º 2
0
        public void Delete(int id)
        {
            Lrp model = _context.lrps.Find(id);

            _context.lrps.Remove(model);
            Save();
        }
Exemplo n.º 3
0
 public Lrp Insert(Lrp lrp)
 {
     _context.lrps.Add(lrp);
     Save();
     return(lrp);
 }
Exemplo n.º 4
0
 public void Update(Lrp Model)
 {
     _context.Entry(Model).State = EntityState.Modified;
     Save();
 }