示例#1
0
        public ActionResult Customer_Create([DataSourceRequest] DataSourceRequest request, Customer customer)
        {
            if (ModelState.IsValid)
            {
                var json = new JavaScriptSerializer().Serialize(customer);
                _UserBAL.LogInsert(DateTime.Now.ToString(), "10", Logs.Insert_Success.ToString(), System.Environment.MachineName, "User tried to insert Customer " + DateTime.UtcNow, "", 0, "Customer", "Customer_Create", json.ToString(), CurrentUser.CompanyID);

                customer.Created_By      = CurrentUser.NameIdentifierInt64;
                customer.Created_Date    = DateTime.UtcNow;
                customer.Organization_ID = CurrentUser.CompanyID;
                var ID = _CustomerBAL.create_CustomerBAL(customer);
                customer.ID = ID;
                var resultData2 = new[] { customer };
                return(Json(resultData2.ToDataSourceResult(request, ModelState)));
            }
            var resultData = new[] { customer };

            return(Json(resultData.ToDataSourceResult(request, ModelState)));
        }
示例#2
0
        public ActionResult Invoice_Create([DataSourceRequest] DataSourceRequest request, InvocieAndDetail _invoice)
        {
            if (ModelState.IsValid)
            {
                var json = new JavaScriptSerializer().Serialize(_invoice);
                _UserBAL.LogInsert(DateTime.Now.ToString(), "10", Logs.Insert_Success.ToString(), System.Environment.MachineName, "User tried to insert Invoice " + DateTime.UtcNow, "", 0, "Invoice", "Invoice_Create", json.ToString(), CurrentUser.CompanyID);
                _invoice.invoice.Generated_By    = CurrentUser.NameIdentifierInt64;
                _invoice.invoice.Generated_Date  = DateTime.UtcNow;
                _invoice.invoice.Invoice_Status  = InvoiceStatus.InvoiceInvented;
                _invoice.invoice.Organization_ID = CurrentUser.CompanyID;
                _invoice.invoice.ID = _CustomerBAL.create_InvoiceBAL(_invoice.invoice);
                InvoiceHistory invoiceHistory = new InvoiceHistory();
                invoiceHistory.History_Name    = "Invoice Create";
                invoiceHistory.Type            = InvoiceStatus.InvoiceInvented;
                invoiceHistory.Description     = "";
                invoiceHistory.Invoice_Number  = _invoice.invoice.ID;
                invoiceHistory.User_ID         = CurrentUser.NameIdentifierInt64;
                invoiceHistory.Organization_ID = CurrentUser.CompanyID;
                invoiceHistory.Date_TIME       = DateTime.Now;
                var x = _CustomerBAL.create_InvoiceHistoryBAL(invoiceHistory);
                foreach (var item in _invoice.invoiceDetails)
                {
                    var jsons = new JavaScriptSerializer().Serialize(_invoice);
                    _UserBAL.LogInsert(DateTime.Now.ToString(), "10", Logs.Insert_Success.ToString(), System.Environment.MachineName, "User tried to insert Invoice Detail at" + DateTime.UtcNow, "", 0, "Invoice", "InvoiceDetail_Create", jsons.ToString(), CurrentUser.CompanyID);
                    item.Invoice_ID = _invoice.invoice.ID;
                    _CustomerBAL.create_InvoiceDetailBAL(item);
                }
                var InvoiceIDd  = _invoice.invoice.ID;
                var resultData2 = new[] { InvoiceIDd };
                return(Json(new { success = true, responseText = InvoiceIDd }, JsonRequestBehavior.AllowGet));
            }
            var InvoiceID  = _invoice.invoice.ID;
            var resultData = new[] { _invoice };

            return(Json(new { success = false, responseText = _invoice }, JsonRequestBehavior.AllowGet));

            //return Json(resultData.ToDataSourceResult(request, ModelState));
        }
示例#3
0
        //[DisableValidation]
        public ActionResult LoginForTrainer(LoginModel infoOfData)
        {
            infoOfData.isOffice365Enabled = false;
            var            c    = _objeobjIOrganizationBAL.OrganizationAllForTrainerbyCultureBAL(CurrentCulture, infoOfData.Email);
            List <DDlList> list = (List <DDlList>)c;

            infoOfData.dDlList = list;
            var json = new JavaScriptSerializer().Serialize(infoOfData);

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", L("Invalidpassword"));
                return(View(infoOfData));
            }
            else
            {
                Users _objUser = this.BALUsers.LoginUserBALForTrainer(infoOfData.Email, infoOfData.OrgnizationId);

                if (_objUser != null && _objUser.UserRole == 2)//check if the email is found
                {
                    DateTime startTime = Convert.ToDateTime(_objUser.LockedOutDate);
                    DateTime endTime   = DateTime.Now;
                    Logger.Info("User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow);
                    TimeSpan span = endTime.Subtract(startTime);

                    if (_objUser.IsLockedOut && span.TotalMinutes <= 10)
                    {
                        BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Locked.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);
                        ModelState.AddModelError("", "User Locked Please try after " + ConfigurationManager.AppSettings["LockedTime"].ToString() + " minutes");

                        //var model = new LoginModel { ReturnUrl = returnUrl, isOffice365Enabled = value, Email = email, dDlList = list }
                        return(View(infoOfData));
                    }
                    if (_objUser.IsLockedOut)
                    {
                        BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Locked.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);
                        ModelState.AddModelError("", "User Locked Please try after " + ConfigurationManager.AppSettings["LockedTime"].ToString() + " minutes");
                        return(View(infoOfData));
                    }
                    //then verify the password
                    if (string.IsNullOrEmpty(_objUser.Password))
                    {
                        ModelState.AddModelError("", L("Invalidpassword"));
                    }
                    else
                    {
                        //  UserHistory userlogin = new UserHistory();
                        //if (_objUser.UserID > 0)
                        //{
                        //    Session["UserID"] = _objUser.UserID;
                        //    userlogin.UserID = _objUser.UserID;
                        //    userlogin.LoginDateTime = DateTime.Now;
                        //    this.BALUsers.Create_UserHistoryBAL(userlogin);
                        //}
                        if (Crypto.VerifyPassword(infoOfData.Password, _objUser.Password))
                        {
                            Logger.Info("User login with email " + infoOfData.Email + " at " + DateTime.UtcNow);
                            Session["CompanyID"]    = _objUser.CompanyID;
                            Session["UserID"]       = _objUser.UserID;
                            userlogin.UserID        = _objUser.UserID;
                            userlogin.LoginDateTime = DateTime.Now;
                            this.BALUsers.Create_UserHistoryBAL(userlogin);
                            IdentitySignin(_objUser, false);
                            BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Susscess.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);
                            return(Redirect(GetRedirectUrl(infoOfData.ReturnUrl)));
                        }
                        else
                        {
                            if (_objUser.LockedOutAttempt >= TMSHelper.FormAuthenticationLockedOutAttemptMax())
                            {
                                BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Attempt.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);
                                this.BALUsers.UpdateUserLockedOutBAL(infoOfData.Email, _objUser.UserID, _objUser.LockedOutAttempt + 1, true);
                                ModelState.AddModelError("", lr.UserLockedOutMessage);
                            }
                            else
                            {
                                this.BALUsers.UpdateUserLockedOutBAL(infoOfData.Email, _objUser.UserID, _objUser.LockedOutAttempt + 1, false);
                                BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Attempt.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);

                                if (_objUser.LockedOutAttempt >= TMSHelper.FormAuthenticationLockedOutAttemptNotifyUser())
                                {
                                    ModelState.AddModelError("", lr.InvalidpasswordWithAttempts + " " + (TMSHelper.FormAuthenticationLockedOutAttemptMax() - _objUser.LockedOutAttempt));
                                }
                                else
                                {
                                    ModelState.AddModelError("", L("Invalidpassword"));
                                }
                            }
                        }
                    }
                }
                else
                {//user is not found with form authentication.
                    BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Attempt.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);

                    ModelState.AddModelError("", L("Invalidpassword"));
                }
                infoOfData.OrgnizationId = 0;
                return(View(infoOfData));
                //return RedirectToAction("LoginForTrainer", new { returnUrl = infoOfData.ReturnUrl, email = infoOfData.Email });
            }
        }
示例#4
0
        // GET: Course
        public ActionResult ManageCourseRelatedExam()
        {
            var json = new JavaScriptSerializer().Serialize(0);

            _UserBAL.LogInsert(DateTime.Now.ToString(), "10", Logs.Insert_Success.ToString(), System.Environment.MachineName, "User tried to read Manage Course Related Exam at" + DateTime.UtcNow, "", 0, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), json.ToString(), CurrentUser.CompanyID);

            return(View());
        }
示例#5
0
        public ActionResult ReportViewer()
        {
            ViewData["reportUrl"] = "~/Report/Tran_ViewCourseAttendanceReport/";
            var json = new JavaScriptSerializer().Serialize("Attendance Report");

            _UserBAL.LogInsert(DateTime.Now.ToString(), "10", Logs.Report_View.ToString(), System.Environment.MachineName, "User tried to view Attendance Report at" + DateTime.UtcNow + " with user id =" + CurrentUser.NameIdentifierInt64, "", 0, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), json.ToString(), CurrentUser.CompanyID);

            return(View());
        }