public ActionResult NewUser(UserDetailsRequest param) { if (!ModelState.IsValid) { return(View()); } ViewBag.Clients = _dolphinApi.GetAllClient(); ViewBag.Roles = _dolphinApi.GetAllRole(); if (param.Password.Any("!@#$%^&*".Contains) && param.Password.Length >= 6) { try { string UserImage = _uploadFile.UploadImage(param.ImgFile); var request = new UserDetailsRequest(); request.FirstName = param.FirstName.ToUpper(); request.MiddleName = param.MiddleName.ToUpper(); request.LastName = param.LastName.ToUpper(); request.Email = param.Email.ToUpper(); request.UserName = param.UserName.ToUpper(); request.Password = _encodingService.EncryptCharacter(param.Password); request.PhoneNo = param.PhoneNo; request.ClientId = param.ClientId; request.RoleId = param.RoleId; request.Sex = param.Sex.ToUpper(); request.UserImg = UserImage; request.IsUserActive = param.IsUserActive; request.CreatedBy = User.Identity.Name.ToUpper(); request.CreatedOn = DateTime.Now; request.Computername = ComputerDetails; request.SystemIp = ipaddress; var success = _dolphinApi.InsertUserRecord(request); if (success.ResponseCode.Equals("00")) { TempData["SuccessMsg"] = success.ResponseMessage; return(RedirectToAction("listuser")); } else { ViewBag.ErrorMsg = success.ResponseMessage; } } catch (Exception ex) { ViewBag.ErrorMsg = ex.Message; } } else { ViewBag.ErrorMsg = "The password must contain special and minimum of six characters"; } return(View()); }
public ActionResult Index(LoginRequest param) { if (!ModelState.IsValid) { return(View()); } try { var request = new LoginRequest(); request.UserName = param.UserName; request.Password = param.Password; request.SystemIp = ipaddress; request.Computername = ComputerDetails; var result = _dolphinApi.ValidateUser(request); if (result == null) { ViewBag.ErrorMsg = "This service is not available"; } else if (result.ResponseCode.Equals("00")) { FormsAuthentication.SetAuthCookie(param.UserName, false); return(RedirectToAction("Dashboard", "Dolphin")); } else if (result.ResponseCode.Equals("10")) { string Id = _encodingService.EncryptCharacter(param.UserName); TempData["ChangePassword"] = result.ResponseMessage; string NewURL = "http://localhost:51310/dolphin/resetpassword?Id=" + Id; Response.Redirect(NewURL, true); } else { ViewBag.ErrorMsg = result.ResponseMessage; } } catch (Exception ex) { ViewBag.ErrorMsg = ex.Message; } return(View()); }