//-----------Add products to cart-----------//
        public static void AddtoCartPL()
        {
            ECEntities ec = new ECEntities();

            try
            {
                Console.Clear();
                Console.WriteLine("*******************************************************************************");
                Console.WriteLine("                                 Add to Cart                          ");
                Console.WriteLine("********************************************************************************");
                Console.WriteLine("Enter the Name of the product:");
                ec.ProdName = Console.ReadLine();
                Console.WriteLine("Add to cart(Yes or No): ");
                ec.Addtocart = Console.ReadLine();

                bool added = ECBL.AddtoCartBL(ec);
                if (added)
                {
                    Console.WriteLine("Product added to cart successfully");
                }
                else
                {
                    Console.WriteLine("Product not added ");
                }
            }
            catch (ECExceptions ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        //Update product---admin//
        public bool UpdateProductDAL(ECEntities ec)
        {
            bool updated = false;

            try
            {
                for (int i = 0; i < ProductList.Count; i++)
                {
                    if (ProductList[i].ProductID == ec.ProductID)
                    {
                        ProductList[i].ProductName = ec.ProductName;
                        ProductList[i].Description = ec.Description;
                        ProductList[i].Quantity    = ec.Quantity;
                        ProductList[i].Price       = ec.Price;
                        updated = true;
                    }
                }
                Serialization();
            }
            catch (SystemException cex)
            {
                throw new ECExceptions(cex.Message);
            }
            return(updated);
        }
Exemple #3
0
        //Delete product--Admin//
        public bool RemoveProductDAL(String id)
        {
            bool removed = false;

            ProductList.Clear();
            Deserialization();
            ECEntities product = new ECEntities();

            try
            {
                product = ProductList.Find(ec => ec.ProductID == id);
                if (product != null)
                {
                    ProductList.Remove(product);
                    removed = true;
                    Serialization();
                }
            }
            catch (SystemException cex)
            {
                throw new ECExceptions(cex.Message);
            }

            return(removed);
        }
Exemple #4
0
        public ActionResult UpdateUser([Bind(Include = "id,first_nm,last_nm,title_ds,email,company_department_id,user_permissions_approve_case_closure,user_permissions_change_settings,company_location_id")] user _user)
        {
            if (!(_user.company_location_id.HasValue) || (_user.company_location_id == 0))
            {
                ModelState.AddModelError("company_location_id", @GlobalRes.Location);
            }
            if (ModelState.IsValid)
            {
                using (var db1 = new ECEntities())
                {
                    user _updateuser = db1.user.Where(item => item.id == _user.id).FirstOrDefault();

                    _updateuser.first_nm            = _user.first_nm;
                    _updateuser.last_nm             = _user.last_nm;
                    _updateuser.title_ds            = _user.title_ds;
                    _updateuser.company_location_id = _user.company_location_id;
                    //_updateuser.notepad_tx = _user.notepad_tx;
                    _updateuser.email = _user.email;
                    //_updateuser.notification_messages_actions_flag = _user.notification_messages_actions_flag;
                    //_updateuser.notification_new_reports_flag = _user.notification_new_reports_flag;
                    _updateuser.company_department_id = _user.company_department_id;
                    _updateuser.user_permissions_approve_case_closure = _user.user_permissions_approve_case_closure;
                    _updateuser.user_permissions_change_settings      = _user.user_permissions_change_settings;
                    db1.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                //TODO: Save your model and redirect
                // _user.Save();

                //     return RedirectToAction("Index");
            }

            user user = (user)Session[ECGlobalConstants.CurrentUserMarcker];

            if (user == null || user.id == 0)
            {
                return(RedirectToAction("Index", "Account"));
            }

            int user_id = user.id;

            UserModel um             = new UserModel(user_id);
            Company   ecModelCompany = new Company();

            um.listDepartments    = ecModelCompany.CompanyDepartments(user.company_id, 1, true);
            ViewBag.um            = um;
            ViewBag.page_subtitle = GlobalRes.Settings;
            ViewBag.user_id       = user_id;
            um._user.user_permissions_approve_case_closure = um._user.user_permissions_approve_case_closure == null ? 2 : um._user.user_permissions_approve_case_closure;
            um._user.user_permissions_change_settings      = um._user.user_permissions_change_settings == null ? 2 : um._user.user_permissions_change_settings;
            return(View("Index", _user));
        }
Exemple #5
0
        //Search product--Admin//
        public ECEntities SearchProductDAL(String id)
        {
            Deserialization();
            ECEntities product = new ECEntities();

            try
            {
                product = ProductList.Find(ec => ec.ProductID == id);
            }
            catch (SystemException cex)
            {
                throw new ECExceptions(cex.Message);
            }
            return(product);
        }
        //-----------Update products-----------//
        public static void UpdateProductPL()
        {
            string productid;

            try
            {
                Console.Clear();
                Console.WriteLine("*******************************************************************************");
                Console.WriteLine("                                 Update Product Details                       ");
                Console.WriteLine("******************************************************************************");
                Console.WriteLine("Enter the Product:(ID)");
                productid = Console.ReadLine();
                ECEntities product = ECBL.SearchProductBL(productid);
                if (product != null)
                {
                    Console.WriteLine("Enter the Name of product:");
                    product.ProductName = Console.ReadLine();
                    Console.WriteLine("Enter the Description:");
                    product.Description = Console.ReadLine();
                    Console.WriteLine("Enter the quantity:");
                    product.Quantity = Console.ReadLine();
                    Console.WriteLine("Enter the price:");
                    product.Price = Console.ReadLine();

                    bool updated = ECBL.UpdateProductBL(product);
                    if (updated)
                    {
                        Console.WriteLine("Product is updated");
                    }
                    else
                    {
                        Console.WriteLine("Product is not updated");
                    }
                }
                else
                {
                    Console.WriteLine("Product ID not found");
                }
            }
            catch (ECExceptions ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #7
0
        //Add product---Admin//
        public bool AddProductDAL(ECEntities plan)
        {
            bool added = false;

            try
            {
                ProductList.Add(plan);
                Serialization();
                added = true;
            }
            catch (SystemException cex)
            {
                throw new ECExceptions(cex.Message);
            }
            return(added);
        }
Exemple #8
0
        //Search product---Admin//
        public static ECEntities SearchProductBL(string ec)
        {
            ECEntities product = new ECEntities();

            try
            {
                ECDAL ed = new ECDAL();
                product = ed.SearchProductDAL(ec);
            }
            catch (ECExceptions ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(product);
        }
        //-------------Adding products---------//
        public static void AddProductPL()
        {
            ECEntities ec = new ECEntities();

            try
            {
                Console.Clear();
                Console.WriteLine("*******************************************************************************");
                Console.WriteLine("                                 Add product Details                           ");
                Console.WriteLine("********************************************************************************");
                Console.WriteLine("Enter the ID");
                ec.ProductID = Console.ReadLine();
                Console.WriteLine("Enter the Name ");
                ec.ProductName = Console.ReadLine();
                Console.WriteLine("Enter the Description ");
                ec.Description = Console.ReadLine();
                Console.WriteLine("Enter the quantity");
                ec.Quantity = Console.ReadLine();
                Console.WriteLine("Enter the price");
                ec.Price = Console.ReadLine();

                bool added = ECBL.AddProductBL(ec);
                if (added)
                {
                    Console.WriteLine("Product added successfully");
                }
                else
                {
                    Console.WriteLine("Product not added ");
                }
            }
            catch (ECExceptions ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #10
0
        //Update product---Admin//
        public static bool UpdateProductBL(ECEntities product)
        {
            bool updated = false;

            try
            {
                if (Validate(product))
                {
                    ECDAL ed = new ECDAL();
                    updated = ed.UpdateProductDAL(product);
                }
            }
            catch (ECExceptions ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(updated);
        }
Exemple #11
0
        //Add product--Admin//
        public static bool AddProductBL(ECEntities ec)
        {
            bool added = false;

            try
            {
                if (Validate(ec))
                {
                    ECDAL ed = new ECDAL();
                    added = ed.AddProductDAL(ec);
                }
            }
            catch (ECExceptions ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(added);
        }
Exemple #12
0
        public static bool Validate(ECEntities ec)
        {
            StringBuilder sb = new StringBuilder();

            bool validate = true;

            try
            {
                if (!validate)
                {
                    throw new ECExceptions(sb.ToString());
                }
            }
            catch (ECExceptions ex)
            {
                throw ex;
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(validate);
        }
Exemple #13
0
        //[HttpPost]
        //EC.Windows.Task.Scheduler.exe http://localhost:8093/Service/Scheduler1?param1=197
        public ActionResult Scheduler1(int param1)
        {
            //Allow sec

            /*if (this.Request.UserHostAddress != "")
             * {
             *  return new JsonResult
             *  {
             *      JsonRequestBehavior = JsonRequestBehavior.AllowGet,
             *      Data = new
             *      {
             *          ok = false,
             *      }
             *  };
             * }*/

            using (var db = new ECEntities())
            {
                var         reports = db.report.ToList();
                ReportModel rm      = new ReportModel();
                string      email   = "";
                Business.Actions.Email.EmailManagement em = new Business.Actions.Email.EmailManagement();
                Business.Actions.Email.EmailBody       eb = new Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower());


                foreach (var _report in reports)
                {
                    rm = new ReportModel(_report.id);
                    if ((rm.GetThisStepDaysLeft() <= 0) && (!db.unread_report_reminder_sent.Any(t => t.report_id == _report.id && t.investigation_status_id == rm._investigation_status)))
                    {
                        eb.Scheduler1(rm._report.display_name);
                        // days are exceeded - reminder never sent - need to send reminder
                        foreach (var user in rm.MediatorsWhoHasAccessToReport())
                        {
                            email = user.email;
                            if ((email != null) && (email.Length > 0))
                            {
                                try
                                {
                                    // em.Send(email, "Case Management Deadline is past due", eb.Body, true);
                                }
                                catch
                                {
                                }
                            }
                        }
                        try
                        {
                            unread_report_reminder_sent _reminder = new unread_report_reminder_sent();
                            _reminder.last_update_dt          = DateTime.Now;
                            _reminder.report_id               = _report.id;
                            _reminder.sent_dt                 = DateTime.Now;
                            _reminder.investigation_status_id = rm._investigation_status;
                            db.unread_report_reminder_sent.Add(_reminder);
                        }
                        catch
                        {
                        }
                    }
                }
            }

            return(new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new {
                    ok = true,
                }
            });
        }
Exemple #14
0
        public string Email(string email)
        {
            if (email != null && email.Length > 0)
            {
                if (m_EmailHelper.IsValidEmail(email.Trim()))
                {
                    ECEntities db = new ECEntities();
                    if (db.user.Any(t => (t.email.ToLower().Trim() == email.ToLower().Trim()) && (t.role_id != 8)))
                    {
                        user _user = (db.user.Where(t => t.email.ToLower().Trim() == email.ToLower().Trim())).First();
                        if (_user != null)
                        {
                            string password_token = Convert.ToBase64String(Guid.NewGuid().ToByteArray());

                            user_change_password _ucp = new user_change_password();
                            _ucp.password_token   = password_token;
                            _ucp.user_id          = _user.id;
                            _ucp.user_ip          = "";
                            _ucp.password_updated = 0;
                            _ucp.created_on       = DateTime.Today;

                            db.user_change_password.Add(_ucp);
                            try
                            {
                                db.SaveChanges();

                                #region Email Sending

                                List <string> to  = new List <string>();
                                List <string> cc  = new List <string>();
                                List <string> bcc = new List <string>();

                                to.Add(email.Trim());
                                ///     bcc.Add("*****@*****.**");

                                EC.Business.Actions.Email.EmailManagement em = new EC.Business.Actions.Email.EmailManagement();
                                EC.Business.Actions.Email.EmailBody       eb = new EC.Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower());
                                eb.ForgetPasswordNew(Request.Url.AbsoluteUri.ToLower(), email, password_token);
                                string body = eb.Body;
                                em.Send(to, cc, App_LocalResources.GlobalRes.ChangePasswordRequest, body, true);

                                #endregion
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.ToString());
                                return(ex.ToString());
                            }
                            return(GlobalRes.Success.ToLower());
                        }
                    }
                    return(GlobalRes.NoUserFound);
                }
                else
                {
                    return(GlobalRes.EmailInvalid);
                }
            }
            else
            {
                return(GlobalRes.EnterYourEmail);
            }
        }
Exemple #15
0
        public ActionResult UpdateMediator([Bind(Include = "id,status_id,role_id")] user _user)
        {
            user session_user = (user)Session[ECGlobalConstants.CurrentUserMarcker];

            if (session_user == null || session_user.id == 0)
            {
                return(RedirectToAction("Index", "Account"));
            }

            if (ModelState.IsValid)
            {
                using (var db1 = new ECEntities())
                {
                    user _updateuser = db1.user.Where(item => item.id == _user.id).FirstOrDefault();
                    _updateuser.status_id = _user.status_id;
                    _updateuser.role_id   = _user.role_id;

                    bool _status_change = false;
                    if ((_user.status_id == 2) && (_updateuser.status_id != 2))
                    {
                        _status_change = true;
                    }

                    bool _role_change = false;

                    if (_user.role_id != _updateuser.role_id)
                    {
                        _role_change = true;
                    }

                    List <string> to  = new List <string>();
                    List <string> cc  = new List <string>();
                    List <string> bcc = new List <string>();

                    CompanyModel cm = new CompanyModel(_user.company_id);

                    EC.Business.Actions.Email.EmailManagement em = new EC.Business.Actions.Email.EmailManagement();
                    EC.Business.Actions.Email.EmailBody       eb = new EC.Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower());
                    string body = "";

                    if (_role_change)
                    {
                        if ((_updateuser.email.Trim().Length > 0) && m_EmailHelper.IsValidEmail(_updateuser.email.Trim()))
                        {
                            to  = new List <string>();
                            cc  = new List <string>();
                            bcc = new List <string>();

                            to.Add(_updateuser.email.Trim());
                            ///     bcc.Add("*****@*****.**");
                            string    new_role   = "";
                            user_role new_roledb = db.user_role.Where(t => t.id == _user.role_id).FirstOrDefault();
                            if (new_roledb != null)
                            {
                                new_role = new_roledb.role_en;
                            }

                            eb.MediatorRoleChange(_updateuser.first_nm, _updateuser.last_nm, session_user.first_nm, session_user.last_nm, new_role);
                            body = eb.Body;
                            em.Send(to, cc, App_LocalResources.GlobalRes.Email_Title_MediatorRoleChanged, body, true);
                        }
                    }
                    if (_status_change)
                    {
                        if ((_updateuser.email.Trim().Length > 0) && m_EmailHelper.IsValidEmail(_updateuser.email.Trim()))
                        {
                            to  = new List <string>();
                            cc  = new List <string>();
                            bcc = new List <string>();

                            to.Add(_updateuser.email.Trim());
                            ///     bcc.Add("*****@*****.**");

                            string new_status = "";
                            status new_roledb = db.status.Where(t => t.id == _user.status_id).FirstOrDefault();
                            if (new_status != null)
                            {
                                new_status = new_roledb.status_en;
                            }

                            eb.MediatorStatusChange(_updateuser.first_nm, _updateuser.last_nm, session_user.first_nm, session_user.last_nm, new_status);
                            body = eb.Body;
                            em.Send(to, cc, App_LocalResources.GlobalRes.Email_Title_MediatorStatusChanged, body, true);
                        }
                    }


                    db1.SaveChanges();
                    return(RedirectToAction("User", new { id = _user.id }));
                }
            }
            return(RedirectToAction("User", new { id = _user.id }));
        }
Exemple #16
0
        public bool AcceptOrReopenCase()
        {
            int    report_id   = Convert.ToInt16(Request["report_id"]);
            int    user_id     = Convert.ToInt16(Request["user_id"]);
            string description = "";// Request["description"];
            int    scopeId     = Convert.ToInt32(Request["scopeId"]);
            int    severityId  = Convert.ToInt32(Request["severityId"]);
            //int departmentId = Convert.ToInt32(Request["departmentId"]);
            //int incidentId = Convert.ToInt32(Request["incidentId"]);
            int  ownerId    = Convert.ToInt32(Request["ownerId"]);
            bool lifeThreat = Convert.ToBoolean(Request["isLifeThreat"]);

            using (ECEntities adv = new ECEntities())
            {
                report_investigation_status addStatus =
                    new report_investigation_status()
                {
                    report_id = report_id,
                    investigation_status_id = 3,
                    created_date            = DateTime.Now,
                    user_id     = user_id,
                    description = description
                };

                adv.report_investigation_status.Add(addStatus);

                var item = db.report_mediator_assigned.FirstOrDefault(x => x.report_id == report_id & x.mediator_id == ownerId);
                if (item == null)
                {
                    //Remove owner
                    foreach (var rem_owner in db.report_owner.Where(x => x.report_id == report_id).ToList())
                    {
                        rem_owner.status_id = 1;
                    }

                    //New owner
                    var owner = new report_owner
                    {
                        report_id  = report_id,
                        status_id  = 2,
                        user_id    = ownerId,
                        created_on = DateTime.Now,
                    };
                    db.report_owner.Add(owner);
                    db.SaveChanges();

                    //Add to mediators
                    var report_mediator_assigned = new report_mediator_assigned
                    {
                        mediator_id    = ownerId,
                        case_owner_id  = owner.id,
                        assigned_dt    = DateTime.Now,
                        last_update_dt = DateTime.Now,
                        report_id      = report_id,
                        status_id      = 2,
                        user_id        = user_id,
                    };
                    db.report_mediator_assigned.Add(report_mediator_assigned);
                    db.SaveChanges();
                }

                adv.SaveChanges();
            }
            using (ECEntities adv = new ECEntities())
            {
                user user = (user)Session[ECGlobalConstants.CurrentUserMarcker];

                var report = adv.report.FirstOrDefault(x => x.id == report_id);
                report.scope_id             = scopeId;
                report.severity_id          = severityId;
                report.severity_user_id     = user.id;
                report.scope_user_id        = user.id;
                report.cc_is_life_threating = lifeThreat;
                report.cc_is_life_threating_created_date = DateTime.Now;
                report.cc_is_life_threating_user_id      = user.id;
                adv.SaveChanges();
            }
            // Case accepted
            glb.UpdateReportLog(user_id, 17, report_id, description, null, "");
            glb.UpdateReportLog(user_id, 20, report_id, App_LocalResources.GlobalRes._Completed, null, "");
            glb.UpdateReportLog(user_id, 21, report_id, App_LocalResources.GlobalRes._Started, null, "");

            report_log _log = new report_log();

            ReportModel  rm = new ReportModel(report_id);
            CompanyModel cm = new CompanyModel(rm._report.company_id);
            UserModel    um = new UserModel(user_id);

            #region Email Ready
            List <string> to  = new List <string>();
            List <string> cc  = new List <string>();
            List <string> bcc = new List <string>();

            EC.Business.Actions.Email.EmailManagement em = new EC.Business.Actions.Email.EmailManagement();
            EC.Business.Actions.Email.EmailBody       eb = new EC.Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower());
            string body = "";
            #endregion

            if (EC.Common.Util.DomainUtil.IsCC(Request))
            {
                if (lifeThreat)
                {
                    glb.UpdateReportLog(user_id, 16, report_id, "", null, "");
                    glb.CampusSecurityAlertEmail(rm._report, Request.Url, db, cm._company.cc_campus_alert_manager_email);
                    glb.CampusSecurityAlertEmail(rm._report, Request.Url, db, cm._company.cc_daily_crime_log_manager_email);
                }
            }

            if (!db.report_log.Any(item => ((item.action_id == 19) && (item.report_id == report_id))))
            {
                //case opened
                glb.UpdateReportLog(user_id, 19, report_id, description, null, "");

                #region Email To Mediators About Case Approved
                foreach (user _user in rm.MediatorsWhoHasAccessToReport())
                {
                    if ((_user.email.Trim().Length > 0) && m_EmailHelper.IsValidEmail(_user.email.Trim()))
                    {
                        to  = new List <string>();
                        cc  = new List <string>();
                        bcc = new List <string>();

                        to.Add(_user.email.Trim());

                        eb.NextStep(_user.first_nm, _user.last_nm, rm._report.display_name);
                        body = eb.Body;

                        ///   em.Send(to, cc, App_LocalResources.GlobalRes.Email_Title_NextStep, body, true);
                    }
                }
                #endregion

                #region Email to Reporter About case been Approved

                if ((rm._reporter_user.email.Trim().Length > 0) && m_EmailHelper.IsValidEmail(rm._reporter_user.email.Trim()))
                {
                    to  = new List <string>();
                    cc  = new List <string>();
                    bcc = new List <string>();

                    to.Add(rm._reporter_user.email.Trim());

                    eb.NextStep(um._user.first_nm, um._user.last_nm, rm._report.display_name);
                    body = eb.Body;

                    em.Send(to, cc, App_LocalResources.GlobalRes.Email_Title_NextStep, body, true);
                }

                #endregion
            }
            else
            {
                // case re-opened
                glb.UpdateReportLog(user_id, 29, report_id, description, null, "");


                #region Email To Mediators About Case re-opening
                foreach (user _user in rm.MediatorsWhoHasAccessToReport())
                {
                    if ((_user.email.Trim().Length > 0) && m_EmailHelper.IsValidEmail(_user.email.Trim()))
                    {
                        to  = new List <string>();
                        cc  = new List <string>();
                        bcc = new List <string>();

                        to.Add(_user.email.Trim());
                        ///     bcc.Add("*****@*****.**");

                        eb.CaseReopened(_user.first_nm, _user.last_nm, rm._report.display_name, um._user.first_nm, um._user.last_nm);
                        body = eb.Body;

                        em.Send(to, cc, App_LocalResources.GlobalRes.Email_Title_CaseReopened, body, true);
                    }
                }
                #endregion

                #region Email to Reporter About case been reopened
                if ((rm._reporter_user.email.Trim().Length > 0) && m_EmailHelper.IsValidEmail(rm._reporter_user.email.Trim()))
                {
                    to  = new List <string>();
                    cc  = new List <string>();
                    bcc = new List <string>();

                    to.Add(rm._reporter_user.email.Trim());
                    ///     bcc.Add("*****@*****.**");

                    eb.ReporterCaseReopened(rm._report.display_name);
                    body = eb.Body;

                    em.Send(to, cc, App_LocalResources.GlobalRes.Email_Title_CaseReopened, body, true);
                }

                #endregion
            }

            /////     glb.UpdateReportLog(user_id, 20, report_id, App_LocalResources.GlobalRes._Completed, null, description);
            //////    glb.UpdateReportLog(user_id, 21, report_id, App_LocalResources.GlobalRes._Started, null, "");

            return(true);
        }