示例#1
0
        public bool ApproveNews(string newsId, bool IsNotify)
        {
            Guid _newsId = new Guid(newsId);
            var  result  = ServerBAL.ApproveNews(_newsId, IsNotify);

            return(result);
        }
示例#2
0
        public ActionResult EditNews(string newsId)
        {
            Guid _newsId = Guid.Parse(newsId);
            generalNewsListReponse newsData = ServerBAL.EditNewsDetails(_newsId);

            return(PartialView("_EditNews", newsData));
        }
示例#3
0
        public NewsDetail AddNews()
        {
            string base64          = string.Empty;
            string CategoryId      = Request.Form.GetValues("CategoryId")[0];//"R-P-T";
            string NewsTitle       = Request.Form.GetValues("NewsTitle")[0];
            string NewsDescription = Request.Form.GetValues("NewsDescription")[0];
            string FileUrl         = Request.Form.GetValues("FileUrl")[0];
            bool   IsNotify        = Convert.ToBoolean(Request.Form.GetValues("IsNotify")[0]);


            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file     = Request.Files[0];
                string             filename = Path.GetFileName(file.FileName);
                if (file.ContentLength > 0)
                {
                    byte[] binaryWriteArray = new byte[file.InputStream.Length];
                    file.InputStream.Read(binaryWriteArray, 0,
                                          (int)file.InputStream.Length);
                    base64 = Convert.ToBase64String(binaryWriteArray);
                }
            }
            else
            {
                using (WebClient client = new WebClient())
                {
                    byte[]               bytes = client.DownloadData(FileUrl);
                    MemoryStream         ms    = new MemoryStream(bytes);
                    System.Drawing.Image img   = System.Drawing.Image.FromStream(ms);
                    bytes  = ms.ToArray();
                    base64 = Convert.ToBase64String(bytes);
                }
            }
            AddNewsRequestModel request = new AddNewsRequestModel();

            request.CategoryId      = Convert.ToInt32(CategoryId);
            request.NewsDescription = NewsDescription;
            request.NewsPhoto       = base64;
            request.NotifyToAll     = IsNotify;
            request.NewsTitle       = NewsTitle;
            //request.NewsPhoto = request.NewsPhoto.Replace("data:image/jpeg;base64,", string.Empty);
            request.CreatedTs = DateTime.Now;
            request.NewsById  = new Guid(Session["UserId"].ToString());
            var result = ServerBAL.AddNews(request);

            return(result);
        }
示例#4
0
        public ActionResult Login(LoginReq model, string returnUrl = "")
        {
            // Lets first check if the Model is valid or not
            if (ModelState.IsValid)
            {
                string username = model.UserId;
                string password = model.Password;

                // Now if our password was enctypted or hashed we would have done the
                // same operation on the user entered password here, But for now
                // since the password is in plain text lets just authenticate directly
                var entities = ServerBAL.AuthenticateUser(model);

                // User found in the database
                if (entities.Success)
                {
                    FormsAuthentication.SetAuthCookie(username, model.RememberMe);
                    Session.Add("FName", entities.FirstName);
                    Session.Add("FullName", string.Join(" ", entities.FirstName, entities.LastName));
                    Session.Add("UserId", entities.UserRegistrationId);
                    ViewBag.UserFname = entities.FirstName;

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            ModelState.Remove("password");
            return(View(model));
        }
示例#5
0
        public bool CreateNewUser(string UserId, string Password, string FirstName, string LastName, string Email, string Mobile, string Gender, int UserType)
        {
            bool       success = false;
            CreateUser req     = new Models.CreateUser();

            req.EmailId   = Email;
            req.FirstName = FirstName;
            req.LastName  = LastName;
            req.UserId    = UserId;
            req.Password  = Password;
            req.MobileNo  = Mobile;
            req.userType  = UserType;
            req.Gender    = Gender;
            var result = ServerBAL.CreateNewUser(req);

            if (result != null)
            {
                return(result.UserId != null);
            }
            return(success);
        }
        public bool LoginAgain(string UserId, string Password)
        {
            bool success  = false;
            var  loginreq = new LoginReq {
                Password = Password, UserId = UserId
            };
            var entities = ServerBAL.AuthenticateUser(loginreq);

            // User found in the database and type of admin & su Admin
            if (entities.Success && (entities.userType == 2 || entities.userType == 3))
            {
                FormsAuthentication.SetAuthCookie(UserId, loginreq.RememberMe);
                Session.Add("FName", entities.FirstName);
                Session.Add("FullName", string.Join(" ", entities.FirstName, entities.LastName));
                Session.Add("UserId", entities.UserRegistrationId);
                Session.Add("UserType", entities.userType);
                success = true;
            }

            return(success);
        }
示例#7
0
        public ActionResult GetUsers()
        {
            var Users = ServerBAL.GetUsers();

            return(PartialView("_UserList", Users));
        }
示例#8
0
        public ActionResult NewsList()
        {
            var result = ServerBAL.NewsList();

            return(PartialView("_NewsList", result));
        }
示例#9
0
        public generalNewsListReponse UpdateNews(string newsId, string newsTitle, string newsDesc, int newsCat)
        {
            var res = ServerBAL.UpdateNews(newsId, newsTitle, newsDesc, newsCat);

            return(res);
        }