Example #1
0
        public ActionResult Login(Client _client)
        {
            ModelState.Clear();
            User _user  = new User();
            var  client = (_clientService.GetClientByClientName(_client.EmailID));

            if (client != null)
            {
                if (_client.EmailID == client.EmailID && _encryptionService.VerifyHashedPassword(_client.Password, client.Password))
                {
                    client.Password = null;
                    client.EmailID  = null;
                    HCRGCLIENT      = Mapper.Map <Client>(client);
                    int orgID    = Int16.Parse(client.OrganizationID);
                    var _orgData = _clientService.GetOrganizationByID(orgID);
                    if (client.ClientTypeID == 2 && _orgData.MenuIDs != null)
                    {
                        var _menuIDS = _orgData.MenuIDs.Split(',');
                        HCRGCLIENT.ClientMenuIDS = _menuIDS.ToList();
                    }
                    _clientService.UpdateClientSessionIDByClientID(client.ClientID, this.Session.SessionID);
                    if (_orgData.LogoImage != null)
                    {
                        HCRGCLIENT.LogoPath = GlobalConst.FolderName.Storage + GlobalConst.ConstantChar.ForwardSlash + GlobalConst.FolderName.Org + orgID + GlobalConst.ConstantChar.ForwardSlash + GlobalConst.FolderName.LogoImage + GlobalConst.ConstantChar.ForwardSlash + _orgData.LogoImage;
                    }
                    return(RedirectToAction(GlobalConst.Actions.HomeContentController.Index, GlobalConst.Controllers.Home, new { area = "" }));
                }
            }
            TempData["Message"] = GlobalConst.Message.InvalidCredentials;
            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult SaveClient(Client _client)
        {
            if (_client.ClientID == 0)
            {
                string semail = "";
                _client.ApproveOn = System.DateTime.Now;
                var clientInfo = _clientService.GetClientByClientName(_client.EmailID);
                if (clientInfo == null)
                {
                    _client.OrganizationID = HCRGCLIENT.OrganizationID;
                    if (_client.IsEmailSent != true)
                    {
                        string subject;
                        string Email;
                        string msg;

                        if (_client.IsActive == true && _client.IsApproved == true)
                        {
                            _client.TempPassword = _encryptionService.GenratePassword(7);
                            _client.Password     = _encryptionService.HashPassword(_client.TempPassword);
                            Email   = _client.EmailID;
                            subject = "Client Registration & New Password";
                            msg     = @"   <p>Hi " + _client.FirstName + " " + _client.LastName + @",</p>
                            <p>Your password is this : " + _client.TempPassword + @"</p>
                            <p>Thanks!</p>";
                            semail  = _mailService.SendRandomPasswordEmail(msg, Email, subject);
                        }
                    }
                    if (semail == GlobalConst.Message.EmailSentSuccessfully)
                    {
                        _client.IsEmailSent = true;
                        _client.ClientID    = _clientService.AddClient(Mapper.Map <NEPService.ClientService.Client>(_client));


                        string folderPath = Server.MapPath(GlobalConst.FolderName.Storage);

                        if (!Directory.Exists(folderPath))
                        {
                            Directory.CreateDirectory(folderPath + GlobalConst.ConstantChar.DoubleBackSlash + GlobalConst.FolderName.Org + _client.OrganizationID + GlobalConst.ConstantChar.DoubleBackSlash + _client.ClientID);
                        }
                        else
                        {
                            string path = folderPath + GlobalConst.ConstantChar.DoubleBackSlash + GlobalConst.FolderName.Org + _client.OrganizationID + GlobalConst.ConstantChar.DoubleBackSlash + _client.ClientID;
                            Directory.CreateDirectory(path);
                        }
                        return(Json(GlobalConst.Message.AddSucessfully, GlobalConst.Message.text_html));
                    }
                    else
                    {
                        return(Json(semail, GlobalConst.Message.text_html));
                    }
                }
                else
                {
                    return(Json(GlobalConst.Message.EmailExist, GlobalConst.Message.text_html));
                }
            }
            else
            {
                string subject;
                string Email;
                string msg;

                string folderPath = Server.MapPath(GlobalConst.FolderName.Storage);
                if (_client.IsEmailSent != true)
                {
                    if (_client.IsActive == true && _client.IsApproved == true)
                    {
                        _client.TempPassword = _encryptionService.GenratePassword(7);
                        _client.Password     = _encryptionService.HashPassword(_client.TempPassword);
                        Email   = _client.EmailID;
                        subject = "Client Registration & New Password";
                        msg     = @"   <p>Hi " + _client.FirstName + " " + _client.LastName + @",</p>
                            <p>Your password is this : " + _client.TempPassword + @"</p>
                            <p>Thanks!</p>";
                        _mailService.SendRandomPasswordEmail(msg, Email, subject);
                        _client.IsEmailSent = true;
                    }
                }

                var clientModel = _clientService.GetClientByID(_client.ClientID);
                _client.Password  = clientModel.Password;
                _client.ApproveOn = clientModel.ApproveOn;
                _client.ClientID  = _clientService.UpdateClient(Mapper.Map <NEPService.ClientService.Client>(_client));
                return(Json(GlobalConst.Message.UpdateSucessfully));
            }
        }