//public ViewResult CreateUser(User u)
        public RedirectToRouteResult CreateUser(User u)
        {
            //       db.Users.Attach(u);
            //db.Users.First(u);
            //if (db.Users.First())
            {
            }
            //User s = db.Users.Find(X = u.Uid);
            // u.Uid = ++count1;
            //u.Email = Request["email"];
            if (i.Add(u))
            {
                Playlist p = new Playlist();
                p.Uid          = u.Uid;
                p.Name         = "Defualt";
                p.UpdationDate = System.DateTime.Now;
                p.CreationDate = System.DateTime.Now;
                //   i.AddPlayList(p);
                //return View();
                user = u;
                this.Session["sessionString"] = u;
                ViewBag.us = u;
                List <Video> vl = u.Videos.ToList();
                ViewBag.list = vl;
                //return RedirectToAction("/Account/PlayList");
                return(RedirectToAction("/PlayList"));
            }
            else
            {
                return(RedirectToAction("LoginError"));
            }
            //db.Users.Add(u);

            //db.SaveChanges();
        }
Beispiel #2
0
        public ActionResult Post(User Model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Data can not be saved"));
                }

                if (UserRepository.AlreadyExists(Model.Email))
                {
                    return(BadRequest("Record already exists"));
                }

                string Message;
                if (!UserRepository.ValidateInput(Model, out Message))
                {
                    return(BadRequest(Message));
                }

                UserRepository.Add(Model);
                UserRepository.Save();

                return(Ok("Record Saved"));
            }
            catch (Exception) { return(BadRequest("Record can not be saved")); }
        }
        public async Task <IActionResult> CrearCuenta([FromBody] Users user)
        {
            try {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                else
                {
                    if (await isUniqueAsync(user: user))
                    {
                        await _user.Add(user);

                        await _estudiante.Add(new Estudiante (IdGet(user).Result));

                        return(Ok("Creado"));
                    }
                    else
                    {
                        return(StatusCode(StatusCodes.Status406NotAcceptable, "Ya existe esa cuenta"));
                    }
                }
            } catch (Exception) {
                return(BadRequest("Ha Ocurrido Un Error Vuelva A Intentar"));
            }
        }
Beispiel #4
0
 public IActionResult Create(User model)
 {
     if (ModelState.IsValid)
     {
         _User.Add(model);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
        public HttpResponseMessage PostUser([FromBody] User user)
        {
            user = userRepository.Add(user);
            var response = Request.CreateResponse <User>(HttpStatusCode.Created, user);
            var uri      = Url.Link("DefaultApi", new { id = user.Id });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
        private void Button_Click_10(object sender, RoutedEventArgs e)
        {
            users u = new users()
            {
                username = "******", password = "******", is_staff = true, empID = "123", cardID = "123456", phoneNumber = "123455", department = "1", mail = "*****@*****.**", IDNum = "88", guid = Guid.NewGuid().ToString()
            };

            MessageBox.Show(User.Add(u).ToString());
        }
Beispiel #7
0
        public IActionResult Create([FromBody] User user)
        {
            if (user == null)
            {
                return(BadRequest());
            }

            service.Add(user);
            return(CreatedAtRoute("GetById", new { id = user.Id }, user));
        }
Beispiel #8
0
        public IActionResult AddUser([FromBody] User model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = _userRepository.Add(model);

            return(Ok(user));
        }
Beispiel #9
0
        public HttpResponseMessage AddUser([FromBody] User model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            var user = _userRepository.Add(model);

            return(Request.CreateResponse(HttpStatusCode.OK, user));
        }
Beispiel #10
0
 /// <summary>
 /// Sets the string value.
 /// </summary>
 /// <param name="key">Key.</param>
 /// <param name="value">Value.</param>
 public static void SetStringValue(this IUser user, string key, string value = null)
 {
     if (user.ContainsKey(key))
     {
         user[key] = value;
     }
     else
     {
         user.Add(key, value);
     }
 }
Beispiel #11
0
 //[ValidateAntiForgeryToken]
 public ActionResult Create(User user)
 {
     if (ModelState.IsValid)
     {
         db.Add(user);
         var model = db.GetByUsername(user.Username);
         return(View("Details", model));
     }
     ;
     return(View());
 }
Beispiel #12
0
 public int Add(User model)
 {
     if (dal != null)
     {
         return(dal.Add(model));
     }
     else
     {
         return(-1);
     }
 }
Beispiel #13
0
 public IHttpActionResult Create(User user)
 {
     if (ModelState.IsValid)
     {
         db.Add(user);
         var model = db.GetAll();
         return(Ok(Json(model)));
     }
     else
     {
         return(BadRequest("Invalid Request!"));
     }
 }
        public async Task <ActionResult <Users> > PostUsers(Users users)
        {
            users.Id = Guid.NewGuid().ToString();

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            await _userService.Add(users);

            return(Created("User Created :", new { id = users.Id }));
        }
Beispiel #15
0
        public async Task <bool> Create(CreateUserViewModel model)
        {
            var user = new User();

            user.Name     = "Admin";
            user.Email    = model.Email;
            user.Hash     = HashMD5.getMD5(model.Email + model.Password + DateTime.Now);
            user.Password = HashMD5.getMD5(model.Password);
            user.Role     = (int)RoleType.Admin;

            await _user.Add(user);

            return(true);
        }
Beispiel #16
0
        public ActionResult AddUser([FromBody] User user)
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            var persianDate = pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now).ToString("00") + "/" + pc.GetDayOfMonth(DateTime.Now).ToString("00");

            user.CreateDate = persianDate;

            Utility.Message message = Models.Utility.ValidatePass(user.UserPassword);
            if (message.Equals(Utility.Message.Success))
            {
                message = _userContext.Add(user);
            }
            string context = message == Utility.Message.Success ? "success" : "error";

            return(new JsonResult(new { Message = Utility.GetMessage(message), context = context }));
        }
Beispiel #17
0
 public ActionResult Create(User user)
 {
     if (getCurrentUser() == null)
     {
         return(RedirectToAction("Index", "Login"));
     }
     else
     {
         try
         {
             if (user.u_role_id != 0)
             {
                 User usercheck = iuser.getUserbyUsername(user.u_name);
                 if (usercheck == null)
                 {
                     var key             = "shdfg2323g3g4j3879sdfh2j3237w8eh";
                     var encryptedString = AesOperaions.EncryptString(key, user.u_password);
                     user.u_password  = encryptedString.ToString();
                     user.u_cre_by    = getCurrentUser().u_id;
                     user.u_cre_date  = DateTime.Now;
                     user.u_active_yn = "Y";
                     iuser.Add(user);
                     return(RedirectToAction(nameof(Index)));
                 }
                 else
                 {
                     ViewBag.RoleList       = (irole.GetRoles);
                     ViewBag.DepartmentList = (idepartment.GetDepartments);
                     ViewBag.Message        = "Username already exsist";
                     return(View());
                 }
             }
             else
             {
                 ViewBag.Message = "Please enter all column";
                 return(View());
             }
         }
         catch (Exception ex)
         {
             ViewBag.RoleList       = (irole.GetRoles);
             ViewBag.DepartmentList = (idepartment.GetDepartments);
             ViewBag.Message        = ex.Message;
             return(View());
         }
     }
 }
Beispiel #18
0
        RegUserResponse IAdminUserService.RegUser()
        {
            var resp = new RegUserResponse();

            try
            {
                var newOne = CreateNewUser();
                _userDAL.Add(newOne);
                resp.Succeed = true;
                resp.LoginId = newOne.UserName;
            }
            catch (Exception ex)
            {
                resp.Message = $"账号注册失败";
                Log(ex);
            }
            return(resp);
        }
Beispiel #19
0
 public IActionResult Add(EmpDetails emp)
 {
     try
     {
         EmpDetails data = _IUser.Add(emp);
         if (!data.Equals(null))
         {
             return(Ok(new { success = true, Message = "Added successfully", Data = emp }));
         }
         else
         {
             return(Ok(new { success = false, Message = "failed to add", Data = emp }));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(new { success = false, Message = ex.Message }));
     }
 }
Beispiel #20
0
 public IActionResult CheckOutBooks([FromBody] List <CheckOut> book)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     else
     {
         string Token = String.Empty;
         Token = Request.Headers["Username"];
         if (Token == "User")
         {
             try
             {
                 foreach (var item in book)
                 {
                     var newUser = new Users()
                     {
                         UserId      = Guid.NewGuid(),
                         FullName    = item.FullName,
                         Email       = item.Email,
                         PhoneNumber = item.PhoneNumber,
                         NationalIdentificationNumber = item.NationalIdentificationNumber,
                         DateOfCheckout       = DateTime.Now,
                         ExpectedDateOfReturn = DateTimeExtensions.AddWorkdays(DateTime.Now, 10),
                         HasReturnedBook      = false
                     };
                     _user.Add(newUser);
                 }
                 return(Ok(book));
             }
             catch (Exception)
             {
                 return(BadRequest());
             }
         }
         else
         {
             return(Unauthorized());
         }
     }
 }
Beispiel #21
0
        public static void Authorization()
        {
            Console.Clear();
            Console.WriteLine("Выберите действие: \n 1.Войти \n 2.Зарегестрироваться");
            switch (Console.ReadLine())
            {
            case "1":
                Console.Clear();
                Console.WriteLine("Введите логин:");
                string Login = Console.ReadLine();
                Console.WriteLine("Введите пароль:");
                string Password = Console.ReadLine();
                userLogic.Authorization(Login, Password);
                ID            = userLogic.FindForLogin(Login);
                authorization = true;
                Menu();
                break;

            case "2":
                Console.Clear();
                Console.WriteLine("Введите ФИО:");
                string FullName = Console.ReadLine();
                Console.WriteLine("Введите дату рождения (DD,MM,YYYY):");
                string[] date = Console.ReadLine().Split(',');

                DateTime DateOfBrith = new DateTime(int.Parse(date[2]), int.Parse(date[1]), int.Parse(date[0]));
                Console.WriteLine("Укажите пол:");
                string Sex = Console.ReadLine();
                Console.WriteLine("Введите логин:");
                string login = Console.ReadLine();
                CheckLogin(ref login);
                Console.WriteLine("Введите пароль:");
                string password = Console.ReadLine();

                userLogic.Add(new User(FullName, DateOfBrith, Sex, login, password));
                ID            = userLogic.FindForLogin(login);
                authorization = true;
                break;
            }
        }
Beispiel #22
0
 /// <summary>
 /// Add插入一条用户记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(IModel model)
 {
     return(dal.Add(model));
 }
Beispiel #23
0
 /// <summary>
 /// 增加user
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddUser(UserModel model)
 {
     return(userService.Add(model));
 }
Beispiel #24
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(BasUser model)
 {
     return(dal.Add(model));
 }
        public virtual async Task <ActionResult> Index(RegisterModel viewModel, string RePassword)
        {
            if (Session["Captcha"] == null || Session["Captcha"].ToString() != viewModel.Captcha)
            {
                ModelState.AddModelError("Captcha", "مجموع اشتباه است");
            }
            if (ModelState.IsValid)
            {
                if (_User.CheckFormat(viewModel.Email, "Email"))
                {
                    if (_User.CheckFormat(viewModel.Password, "Password"))
                    {
                        if (RePassword == viewModel.Password)
                        {
                            if (_User.CheckEmail(viewModel.Email))
                            {
                                if (!_User.CheckActiveEmail(viewModel.Email))
                                {
                                    _VerifyUser.SendVerifyEmail(_User.GetUserID(viewModel.Email), viewModel.Email, "VerifyEmail");
                                    return(RedirectToAction("SuccessMessage", "Home", new { area = "" }));
                                }
                                else
                                {
                                    ViewBag.Message = "این ایمیل در سیستم پارسی بین قبلا به ثبت رسیده است. ";
                                    return(View());
                                }
                            }
                            else
                            {
                                var item = new RegisterModel
                                {
                                    Email    = viewModel.Email,
                                    Password = viewModel.Password
                                };
                                _User.Add(item);
                                await _uow.SaveChangesAsync();

                                return(RedirectToAction("SuccessMessage", "Home", new { area = "" }));
                            }
                        }
                        else
                        {
                            ViewBag.Message = "کلمه عبور به درستی تکرار نشده است.";
                            return(View());
                        }
                    }
                    else
                    {
                        ViewBag.Message = "انتخاب این رمز عبور مجاز نمیباشد.";
                        return(View());
                    }
                }
                else
                {
                    ViewBag.Message = "ایمیل وارد شده در سیستم به عنوان ایمیل معتبر شناخته نشد.";
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Beispiel #26
0
 public async Task <IActionResult> CreateUser(User user)
 {
     //_context.Add(user);
     _userService.Add(user);
     return(Ok(await _userService.SaveAsync()));
 }
Beispiel #27
0
 public void AddUser(User u)
 {
     userRepository.Add(u);
 }
Beispiel #28
0
 /// <summary>
 /// 新增一条数据
 /// </summary>
 /// <param name="model">ADT.XingZhi.Models.S.User</param>
 /// <param name="userRoleDT">用户角色信息DataTable</param>
 public int Add(ADT.XingZhi.Models.S.User model, DataTable userRoleDT)
 {
     return(dal.Add(model, userRoleDT));
 }
Beispiel #29
0
 public static int Add(UserInfo entity)
 {
     return(dal.Add(entity));
 }
Beispiel #30
0
 public bool Add(users us)
 {
     return(ist.Add(us));
 }