예제 #1
0
        public async Task <ActionResult> AddParrain(ParrainViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await dal.GetUsersList().FirstOrDefaultAsync(m => m.Email == model.Email);

                if (user != null)
                {
                    var parrain = new ParrainModel()
                    {
                        Date_createParrain = DateTime.Now,
                        ParrainEmail       = user.Email,
                        ParrainFirstName   = user.FirstName
                    };
                    dal.AddParrain(parrain);
                    return(RedirectToAction("ListAllAgents"));
                }
                else
                {
                    return(RedirectToAction("ListAllAgents"));
                }
            }
            return(RedirectToAction("ListAllAgents"));
        }