Exemplo n.º 1
0
        /*******Begin code to modify********/

        /// <summary>
        /// Create a new user of the LMS with the specified information.
        /// Assigns the user a unique uID consisting of a 'u' followed by 7 digits.
        /// </summary>
        /// <param name="fName">First Name</param>
        /// <param name="lName">Last Name</param>
        /// <param name="DOB">Date of Birth</param>
        /// <param name="SubjectAbbrev">The department the user belongs to (professors and students only)</param>
        /// <param name="SubjectAbbrev">The user's role: one of "Administrator", "Professor", "Student"</param>
        /// <returns>A unique uID that is not be used by anyone else</returns>
        public string CreateNewUser(string fName, string lName, DateTime DOB, string SubjectAbbrev, string role)
        {
            String nextUid = "not filled";

            using (Team31LMSContext db = new Team31LMSContext())
            {
                var all_uIds = (from stud in db.Students orderby stud.UId descending select new { uId = stud.UId })
                               .Union(from prof in db.Professors orderby prof.UId descending select new { uId = prof.UId })
                               .Union(from adm in db.Administrators orderby adm.UId descending select new { uId = adm.UId });

                var uIds = all_uIds.OrderByDescending(x => x.uId).Take(1);

                // get new Uid
                String highestUid       = uIds.First().uId.ToString();
                int    highestUidNumber = Int32.Parse(highestUid.Substring(1, highestUid.Length - 1));
                int    nextUidNumber    = highestUidNumber + 1;
                nextUid = "u" + nextUidNumber.ToString();


                // chose role
                if (role == "Student")
                {
                    Students st = new Students
                    {
                        UId       = nextUid,
                        FirstName = fName,
                        LastName  = lName,
                        Dob       = DOB,
                        Major     = SubjectAbbrev
                    };
                    db.Students.Add(st);
                    db.SaveChanges();
                }
                else if (role == "Professor")
                {
                    Professors pr = new Professors
                    {
                        UId       = nextUid,
                        FirstName = fName,
                        LastName  = lName,
                        Dob       = DOB,
                        Works     = SubjectAbbrev
                    };
                    db.Professors.Add(pr);
                    db.SaveChanges();
                }
                else if (role == "Administrator")
                {
                    Administrators ad = new Administrators
                    {
                        UId       = nextUid,
                        FirstName = fName,
                        LastName  = lName,
                        Dob       = DOB
                    };
                    db.Administrators.Add(ad);
                    db.SaveChanges();
                }
            }

            return(nextUid);
        }
Exemplo n.º 2
0
        /*******Begin code to modify********/

        /// <summary>
        /// Create a new user of the LMS with the specified information.
        /// Assigns the user a unique uID consisting of a 'u' followed by 7 digits.
        /// </summary>
        /// <param name="fName">First Name</param>
        /// <param name="lName">Last Name</param>
        /// <param name="DOB">Date of Birth</param>
        /// <param name="SubjectAbbrev">The department the user belongs to (professors and students only)</param>
        /// <param name="SubjectAbbrev">The user's role: one of "Administrator", "Professor", "Student"</param>
        /// <returns>A unique uID that is not be used by anyone else</returns>
        public string CreateNewUser(string fName, string lName, DateTime DOB, string SubjectAbbrev, string role)
        {
            var query = from s in db.Students
                        select s.UId;

            var query2 = from s2 in db.Professors
                         select s2.UId;
            var query3 = from s3 in db.Professors
                         select s3.UId;

            int max = 0;

            foreach (var x in query)
            {
                String uid = x.Substring(1);
                int    id  = Int32.Parse(uid);

                if (id > max)
                {
                    max = id;
                }
            }
            foreach (var x in query2)
            {
                String uid = x.Substring(1);
                int    id  = Int32.Parse(uid);

                if (id > max)
                {
                    max = id;
                }
            }

            foreach (var x in query3)
            {
                String uid = x.Substring(1);
                int    id  = Int32.Parse(uid);

                if (id > max)
                {
                    max = id;
                }
            }

            max += 1;
            String newId = max.ToString();

            while (newId.Length < 7)
            {
                newId = '0' + newId;
            }
            newId = 'u' + newId;

            if (role == "Student")
            {
                Students s = new Students();
                s.UId       = newId;
                s.FirstName = fName;
                s.LastName  = lName;
                s.Dob       = DOB.ToString();
                s.DeptMajor = SubjectAbbrev;

                db.Students.Add(s);
                db.SaveChanges();
            }
            else if (role == "Professor")
            {
                Professors p = new Professors();
                p.UId         = newId;
                p.FirstName   = fName;
                p.LastName    = lName;
                p.Dob         = DOB.ToString();
                p.DeptWorksIn = SubjectAbbrev;

                db.Professors.Add(p);
                db.SaveChanges();
            }
            else if (role == "Administrator")
            {
                Administrators a = new Administrators();
                a.UId       = newId;
                a.FirstName = fName;
                a.LastName  = lName;
                a.Dob       = DOB.ToString();


                db.Administrators.Add(a);
                db.SaveChanges();
            }
            return(newId);
        }
Exemplo n.º 3
0
        private void InsertExcelRecords(string FilePath)
        {
            List <Product> _products   = new List <Product>();
            var            csvData     = System.IO.File.ReadAllLines(FilePath).Skip(1);
            int            insertCount = 0;
            int            updateCount = 0;

            try
            {
                //Execute a loop over the rows.
                foreach (string row in csvData)
                {
                    if (!string.IsNullOrEmpty(row))
                    {
                        if (row != ",,,,,,,,,,,,,,,,")
                        {
                            _products.Add(new Product
                            {
                                Product_Id             = Convert.ToInt32(row.Split(',')[0]),
                                SubCategory_Id         = Convert.ToInt32(row.Split(',')[1]),
                                Product_Title          = row.Split(',')[2],
                                Product_Description    = row.Split(',')[3],
                                Product_Specification  = row.Split(',')[4],
                                Product_Qty            = Convert.ToInt32(row.Split(',')[5]),
                                Product_Qty_Alert      = Convert.ToInt32(row.Split(',')[6]),
                                Product_Delivery_Time  = Convert.ToInt32(row.Split(',')[7]),
                                Product_Max_Purchase   = Convert.ToInt32(row.Split(',')[8]),
                                Product_Mkt_Price      = Convert.ToDecimal(row.Split(',')[9]),
                                Product_Our_Price      = Convert.ToDecimal(row.Split(',')[10]),
                                Product_ShippingCharge = Convert.ToDecimal(row.Split(',')[11]),
                                Product_Has_Size       = Convert.ToBoolean(row.Split(',')[12].ToLower()),
                                Product_Size           = row.Split(',')[13],
                                Product_Avail_ZipCode  = row.Split(',')[14],
                                Product_Discount       = Convert.ToDecimal(row.Split(',')[15]),
                                Product_CreatedDate    = DateTime.Now,
                                Product_UpdatedDate    = DateTime.Now,
                                Product_Status         = eProductStatus.ReviewPending.ToString()
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            int            AdminId = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString());
            Administrators _admin  = context.Administrator.ToList().Where(m => m.Administrators_Id == AdminId).FirstOrDefault();

            foreach (var item in _products)
            {
                SubCategories _subCategory = context.SubCategory.Where(m => m.SubCategory_Id == item.SubCategory_Id).FirstOrDefault();
                item.Administrators_Id = _admin.Administrators_Id;
                item.Store_Id          = _admin.Store_Id;
                if (_subCategory != null)
                {
                    if (item.Product_Id == 0)
                    {
                        Product Product = new Product()
                        {
                            Store_Id               = _admin.Store_Id,
                            Product_Title          = item.Product_Title,
                            Product_Description    = item.Product_Description,
                            Product_Specification  = item.Product_Specification,
                            Administrators_Id      = _admin.Administrators_Id,
                            Product_Qty            = item.Product_Qty,
                            Product_Qty_Alert      = item.Product_Qty_Alert,
                            Product_Delivery_Time  = item.Product_Delivery_Time,
                            Product_Max_Purchase   = item.Product_Max_Purchase,
                            Product_Mkt_Price      = item.Product_Mkt_Price,
                            Product_Our_Price      = item.Product_Our_Price,
                            Product_ShippingCharge = item.Product_ShippingCharge,
                            Product_Has_Size       = item.Product_Has_Size,
                            Product_Size           = (item.Product_Has_Size == true) ? item.Product_Size : "No Size",
                            Product_Avail_ZipCode  = item.Product_Avail_ZipCode,
                            Product_Discount       = item.Product_Discount,
                            SubCategory_Id         = item.SubCategory_Id,
                            Product_CreatedDate    = item.Product_CreatedDate,
                            Product_UpdatedDate    = item.Product_UpdatedDate,
                            Product_Status         = item.Product_Status
                        };
                        try
                        {
                            int maxAdminId = 1;
                            if (context.Product.ToList().Count > 0)
                            {
                                maxAdminId = context.Product.Max(m => m.Product_Id);
                            }
                            maxAdminId          = (maxAdminId == 1 && context.Product.ToList().Count > 0) ? (maxAdminId + 1) : maxAdminId;
                            Product.ProductCode = "PRDTRACH" + maxAdminId + "TERA" + (maxAdminId + 1);
                            context.Product.Add(Product);
                            context.SaveChanges();

                            ProductHelper.CreateProductFlow(Product.Product_Id, Product.Product_Title, _admin.Administrators_Id, _admin.FullName, "New Product Created", Product.Product_Status);

                            item.Product_Id = Product.Product_Id;
                            insertCount     = insertCount + 1;
                            ProductBanners ProductBanner = new ProductBanners()
                            {
                                Product_Id                 = Product.Product_Id,
                                Administrators_Id          = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()),
                                Product_Banner_Default     = 1,
                                Product_Banner_Photo       = "content/noimage.png",
                                Product_Banner_CreatedDate = DateTime.Now,
                                Product_Banner_UpdatedDate = DateTime.Now
                            };

                            int maxBnrAdminId = 1;
                            if (context.ProductBanner.ToList().Count > 0)
                            {
                                maxBnrAdminId = context.ProductBanner.Max(m => m.Product_Id);
                            }
                            maxBnrAdminId = (maxBnrAdminId == 1 && context.ProductBanner.ToList().Count > 0) ? (maxBnrAdminId + 1) : maxBnrAdminId;
                            ProductBanner.Product_BannerCode = "PRDBNRTRACH" + maxBnrAdminId + "TERA" + (maxBnrAdminId + 1);
                            context.ProductBanner.Add(ProductBanner);
                            context.SaveChanges();
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        Product _product = context.Product.ToList().Where(m => m.Product_Id == item.Product_Id).FirstOrDefault();
                        if (_product != null)
                        {
                            _product.Store_Id               = _admin.Store_Id;
                            _product.Product_Title          = item.Product_Title;
                            _product.Product_Description    = item.Product_Description;
                            _product.Product_Specification  = item.Product_Specification;
                            _product.Administrators_Id      = _admin.Administrators_Id;
                            _product.Product_Qty            = item.Product_Qty;
                            _product.Product_Qty_Alert      = item.Product_Qty_Alert;
                            _product.Product_Delivery_Time  = item.Product_Delivery_Time;
                            _product.Product_Max_Purchase   = item.Product_Max_Purchase;
                            _product.Product_Mkt_Price      = item.Product_Mkt_Price;
                            _product.Product_Our_Price      = item.Product_Our_Price;
                            _product.Product_ShippingCharge = item.Product_ShippingCharge;
                            _product.Product_Size           = item.Product_Size;
                            _product.Product_Avail_ZipCode  = item.Product_Title;
                            _product.Product_Discount       = item.Product_Discount;
                            _product.SubCategory_Id         = item.SubCategory_Id;
                            _product.Product_UpdatedDate    = item.Product_UpdatedDate;
                            _product.Product_Status         = item.Product_Status;

                            try
                            {
                                updateCount = updateCount + 1;
                                context.Entry(_product).State = System.Data.Entity.EntityState.Modified;
                                context.SaveChanges();
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            item.Product_Status = "Invalid Product Id";
                        }
                    }
                }
                else
                {
                    item.Product_Status = "Invalid Sub Category Id";
                }
            }
            pnlErrorMessage.Attributes.Remove("class");
            pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable";
            pnlErrorMessage.Visible             = true;
            lblMessage.Text = "We are done!! " + insertCount + " Products Inserted and " + updateCount + " Products Updated Successfully also we have dowloaded the updated excel. Please check your download folder.";

            DataTable dt = ConvertToDataTable(_products);

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Products.xls"));
            Response.ContentType = "application/ms-excel";
            string str = string.Empty;

            foreach (DataColumn dtcol in dt.Columns)
            {
                Response.Write(str + dtcol.ColumnName);
                str = "\t";
            }
            Response.Write("\n");
            foreach (DataRow dr in dt.Rows)
            {
                str = "";
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    Response.Write(str + Convert.ToString(dr[j]));
                    str = "\t";
                }
                Response.Write("\n");
            }
            Response.End();
        }
Exemplo n.º 4
0
 public void AddAdministrator(User u)
 {
     Administrators.Add(u);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Je skupina administrovaná členem?
 /// </summary>
 /// <param name="user">testovaný uživatel</param>
 /// <returns></returns>
 public bool IsAdminedBy(User user)
 {
     return(Administrators.Contains(user));
 }
        public ActionResult SubmitOrder(string addressId, string paymentType)
        {
            int          custId         = Convert.ToInt32(Session["UserKey"]);
            Customers    _cust          = bCustomer.List().Where(m => m.Customer_Id == custId).FirstOrDefault();
            int          custAdrId      = Convert.ToInt32(addressId);
            int          selPaymentType = Convert.ToInt32(paymentType);
            List <Carts> _cart          = _mcartmdl.GetCarts().Where(m => m.Customer_Id == custId && m.Cart_Status == eCartStatus.Open.ToString()).ToList();
            string       _res           = string.Empty;

            foreach (var item in _cart)
            {
                Product _prd = context.Product.Where(m => m.Product_Id == item.Product_Id).FirstOrDefault();

                Order Orders = new Order()
                {
                    Order_Price          = item.Cart_Price,
                    Order_Qty            = item.Cart_Qty,
                    Order_Size           = item.Cart_Size,
                    Order_Status         = eOrderStatus.Placed.ToString(),
                    Product_Id           = item.Product_Id,
                    Product_Banner       = item.Product_Banner,
                    Product_Price        = item.Product_Price,
                    Product_Title        = item.Product_Title,
                    Customer_Id          = item.Customer_Id,
                    Customer_Name        = item.Customer_Name,
                    CustomerAddress_Id   = custAdrId,
                    Payment_Method_Id    = selPaymentType,
                    Order_Date           = DateTime.Now,
                    Order_Delievery_Date = DateTime.Now.AddDays(_prd.Product_Delivery_Time),
                    Store_Id             = _prd.Store_Id,
                    Order_UpdateDate     = DateTime.Now
                };

                int maxBnrCusAdrAdminId = 1;
                if (context.Orders.ToList().Count > 0)
                {
                    maxBnrCusAdrAdminId = context.Orders.Max(m => m.Order_Id);
                }
                maxBnrCusAdrAdminId = (maxBnrCusAdrAdminId == 1 && context.Orders.ToList().Count > 0) ? (maxBnrCusAdrAdminId + 1) : maxBnrCusAdrAdminId;
                Orders.Order_Code   = "ORDRACH" + maxBnrCusAdrAdminId + "TERA" + (maxBnrCusAdrAdminId + 1);
                context.Orders.Add(Orders);
                context.SaveChanges();

                Administrators _adm           = context.Administrator.Where(m => m.EmailId == "*****@*****.**").FirstOrDefault();
                OrderHistory   OrderHistories = new OrderHistory()
                {
                    Order_Id                 = Orders.Order_Id,
                    OrderHistory_Status      = eOrderStatus.Placed.ToString(),
                    OrderHistory_Description = "Order Submitted successfully on " + DateTime.Now.ToString("D").ToString(),
                    OrderHistory_CreatedDate = DateTime.Now,
                    OrderHistory_UpdatedDate = DateTime.Now,
                    Administrators_Id        = _adm.Administrators_Id,
                    Store_Id                 = Orders.Store_Id
                };

                context.OrderHistories.Add(OrderHistories);
                context.SaveChanges();

                Carts _carts = _mcartmdl.GetCarts().Where(m => m.Cart_Id == item.Cart_Id).FirstOrDefault();
                _mcartmdl.DeleteCartByCartId(_carts);

                string productUrl = "http://rachnateracotta.com/product/index?id=" + item.Product_Id;
                _res = _res + "<tr style='border: 1px solid black;'><td style='border: 1px solid black;'><img src='" + ConfigurationSettings.AppSettings["DomainUrl"].ToString() + item.Product_Banner + "' width='100' height='100'/></td>"
                       + "<td style='border: 1px solid black;'><a href='" + productUrl + "'>" + item.Product_Title + "</a></td><td style='border: 1px solid black;'> Total Quantity :" + item.Cart_Qty + " </td><td style='border: 1px solid black;'> " + item.Cart_Price + " </td></tr>";
            }
            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
            {
                string host = string.Empty;
                host = "<table style='width:100%'>" + _res + "</ table >";
                string body = MailHelper.CustomerOrderPlaced(host, (_cust.Customers_FullName));
                MailHelper.SendEmail(_cust.Customers_EmailId, "Success!!! You Order Placed In Rachna Teracotta Estore.", body, "Rachna Teracotta Order Placed");
            }
            return(Json("success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
    public bool ChangeStatus(int UserID, int JobpostingID, string Status, string Date)
    {
        Administrators administrationManager = new Administrators();

        return(administrationManager.UpdateCandidateJobStatus(UserID, JobpostingID, Status, Date));
    }
Exemplo n.º 8
0
        protected void ExportToExcel(object sender, EventArgs e)
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls");
            Response.Charset     = "";
            Response.ContentType = "application/vnd.ms-excel";
            using (StringWriter sw = new StringWriter())
            {
                HtmlTextWriter hw = new HtmlTextWriter(sw);

                //To Export all pages
                grdStoreOrders.AllowPaging = false;
                if (ddlStatus.Text == "" || txtStartDate.Text != "" || txtEndDate.Text != "")
                {
                    LoadDetail();
                }
                else
                {
                    using (var ctx = new RachnaDBContext())
                    {
                        Administrators _Administrator = null;
                        _Administrator = bAdministrator.List().Where(m => m.Administrators_Id == Convert.ToInt32(Session[ConfigurationSettings.AppSettings["VendorSession"].ToString()].ToString())).FirstOrDefault();
                        int storeId = _Administrator.Store_Id;
                        _RequestList = context.Orders.Where(m => m.Store_Id == storeId).ToList();
                        if (_RequestList == null)
                        {
                            btnExport.Visible = false;
                        }
                        grdStoreOrders.DataSource = _RequestList;
                        grdStoreOrders.DataBind();
                    }
                }
                grdStoreOrders.HeaderRow.BackColor = Color.White;
                foreach (TableCell cell in grdStoreOrders.HeaderRow.Cells)
                {
                    cell.BackColor = grdStoreOrders.HeaderStyle.BackColor;
                }
                foreach (GridViewRow row in grdStoreOrders.Rows)
                {
                    row.BackColor = Color.White;
                    foreach (TableCell cell in row.Cells)
                    {
                        if (row.RowIndex % 2 == 0)
                        {
                            cell.BackColor = grdStoreOrders.AlternatingRowStyle.BackColor;
                        }
                        else
                        {
                            cell.BackColor = grdStoreOrders.RowStyle.BackColor;
                        }

                        cell.CssClass = "textmode";
                    }
                }

                grdStoreOrders.RenderControl(hw);

                //style to format numbers to string
                string style = @"<style> .textmode { } </style>";
                Response.Write(style);
                Response.Output.Write(sw.ToString());
                Response.Flush();
                Response.End();
            }
        }
Exemplo n.º 9
0
 public WSRContext()
 {
     //if (!(Database.GetService<IDatabaseCreator>() as RelationalDatabaseCreator).Exists())
     Database.EnsureDeleted();
     Database.EnsureCreated();
     if (!Participants.Any())
     {
         string DPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\"));
         DPath += "\\CSV\\";
         Database.OpenConnection();
         using (var reader = new StreamReader(DPath + "Participants.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Participants.AddRange(csv.GetRecords <Participant>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Participants ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Participants OFF;");
         using (var reader = new StreamReader(DPath + "Experts.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Experts.AddRange(csv.GetRecords <Expert>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Experts ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Experts OFF;");
         using (var reader = new StreamReader(DPath + "Admins.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Administrators.AddRange(csv.GetRecords <Administrator>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Administrators ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Administrators OFF;");
         using (var reader = new StreamReader(DPath + "Coordinators.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Coordinators.AddRange(csv.GetRecords <Coordinator>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Coordinators ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Coordinators OFF;");
         List <Competention> temp = new List <Competention>();
         using (var reader = new StreamReader(DPath + "Competentions.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 temp.AddRange(csv.GetRecords <Competention>());
             }
         using (var reader = new StreamReader(DPath + "CompetentionDesc.txt", Encoding.Default))
         {
             Competention CurrC;
             for (int Counter = 1; Counter <= temp.Count; Counter++)//relies on competencies being consequentioal from 1
             {
                 CurrC             = temp.FirstOrDefault(c => c.Id == Counter);
                 CurrC.Description = reader.ReadLine();
             }
         }
         Competentions.AddRange(temp);
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Competentions ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Competentions OFF;");
         using (var reader = new StreamReader(DPath + "Championships.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Championships.AddRange(csv.GetRecords <Championship>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Championships ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Championships OFF;");
         using (var reader = new StreamReader(DPath + "Infrastructures.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Infrastructures.AddRange(csv.GetRecords <Infrastructure>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Infrastructures ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Infrastructures OFF;");
         using (var reader = new StreamReader(DPath + "SMPs.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 SMPs.AddRange(csv.GetRecords <SMP>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.SMPs ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.SMPs OFF;");
         using (var reader = new StreamReader(DPath + "Results.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Results.AddRange(csv.GetRecords <Result>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Results ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Results OFF;");
         using (var reader = new StreamReader(DPath + "Sponsors.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Sponsors.AddRange(csv.GetRecords <Sponsor>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Sponsors ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Sponsors OFF;");
         using (var reader = new StreamReader(DPath + "Volunteers.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Volunteers.AddRange(csv.GetRecords <Volunteer>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Volunteers ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Volunteers OFF;");
         Database.CloseConnection();
     }
 }
Exemplo n.º 10
0
 /// <summary>Find out if a principal has a certain permission by default.</summary>
 /// <param name="user">The principal to check for allowance.</param>
 /// <param name="permission">The type of permission to map against.</param>
 /// <returns>True if the system is configured to allow the user to the given permission.</returns>
 public virtual bool IsAuthorized(IPrincipal user, Permission permission)
 {
     return((Administrators.MapsTo(permission) && Administrators.Contains(user)) ||
            (Editors.MapsTo(permission) && Editors.Contains(user)) ||
            (Writers.MapsTo(permission) && Writers.Contains(user)));
 }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                Administrators _admin = bAdministrator.List().Where(m => m.EmailId == txtUserName.Text).FirstOrDefault();

                if (_admin == null)
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblErrorMessage.Text = "Oops!!! No entered email id exists in our database.";
                }
                else if (_admin.Admin_Status == "inactive")
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblErrorMessage.Text = "Oops!!! Cannot login to your account, becaues your account is inactive. Please raise request to activate your account.";
                }
                else if (_admin.Admin_Login_Attempt > 5)
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblErrorMessage.Text = "Oops!!! Cannot login to your account, becaues your account is locked. Please raise request to unlock your account.";
                }
                else if (_admin.Password != txtPassword.Text && _admin.Admin_Login_Attempt < 5)
                {
                    _admin.Admin_Login_Attempt = (_admin.Admin_Login_Attempt + 1);
                    _admin.Admin_UpdatedDate   = DateTime.Now;
                    _admin = bAdministrator.Update(_admin);
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblErrorMessage.Text = "Oops!!! Entered password is invalid for entered emailid.";
                }
                else
                {
                    ActivityHelper.Create("Login", "Loogged In on " + DateTime.Now.ToString("D") + " Successfully", _admin.Administrators_Id);
                    pnlErrorMessage.Visible = false;
                    lblErrorMessage.Text    = "";
                    if (_admin.Admin_Role != eRole.Vendor.ToString())
                    {
                        Session[ConfigurationSettings.AppSettings["SupportSession"].ToString()] = _admin.Administrators_Id;
                        if (_admin.Admin_Login_Attempt != 0)
                        {
                            _admin.Admin_Login_Attempt = 0;
                            _admin.Admin_UpdatedDate   = DateTime.Now;
                            _admin = bAdministrator.Update(_admin);
                        }
                        if (Session["PreviousUrl"] != null)
                        {
                            Response.Redirect(Session["PreviousUrl"].ToString(), false);
                        }
                        else
                        {
                            Response.Redirect("/support/home/default.aspx?redirecturl=rachna-teracotta-home");
                        }
                    }
                    else
                    {
                        pnlErrorMessage.Attributes.Remove("class");
                        pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                        pnlErrorMessage.Visible             = true;
                        lblErrorMessage.Text = "Oops!! You are not authorized user to access this page.";
                    }
                }
            }
            catch (Exception ex)
            {
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblErrorMessage.Text = "Oops!! Server error occured, please contact administrator.";
            }
        }
Exemplo n.º 12
0
        private bool IsDuplicateName(string _name)
        {
            var q = Administrators.Count(x => x.Name == _name);

            return(q > 1);
        }
Exemplo n.º 13
0
 //Delete
 private bool CanExecuteDelete(object obj)
 {
     return(Administrators.Count(x => x.Selected) > 0);
 }
Exemplo n.º 14
0
        /*******Begin code to modify********/

        /// <summary>
        /// Create a new user of the LMS with the specified information.
        /// Assigns the user a unique uID consisting of a 'u' followed by 7 digits.
        /// </summary>
        /// <param name="fName">First Name</param>
        /// <param name="lName">Last Name</param>
        /// <param name="DOB">Date of Birth</param>
        /// <param name="SubjectAbbrev">The department the user belongs to (professors and students only)</param>
        /// <param name="SubjectAbbrev">The user's role: one of "Administrator", "Professor", "Student"</param>
        /// <returns>A unique uID that is not be used by anyone else</returns>
        public string CreateNewUser(string fName, string lName, DateTime DOB, string SubjectAbbrev, string role)
        {
            string uID = "";

            using (db = new Team77LMSContext())
            {
                var query =
                    (from p in db.Users
                     orderby p.UId descending
                     select p.UId).Take(1);

                /*
                 * System.Diagnostics.Debug.WriteLine("----------");
                 * System.Diagnostics.Debug.WriteLine(query.ToArray()[0]);
                 * System.Diagnostics.Debug.WriteLine(query.ToArray()[1]);
                 * System.Diagnostics.Debug.WriteLine(query.ToArray()[2]);
                 * System.Diagnostics.Debug.WriteLine("----------");
                 */

                if (query.ToArray().Count() != 0)
                {
                    // System.Diagnostics.Debug.WriteLine("0");
                    uID = query.ToArray()[0];
                }
                else
                {
                    uID = "first";
                }
            }
            if (uID != "first")
            {
                uID = uID.Substring(1, 7);
                int temp = Int32.Parse(uID) + 1;
                uID = 'u' + temp.ToString();
                while (uID.Count() < 8)
                {
                    uID = uID.Insert(1, "0");
                }
            }
            else
            {
                uID = "u0000000";
            }

            using (db = new Team77LMSContext())
            {
                Users user = new Users();
                user.UId   = uID;
                user.FName = fName;
                user.LName = lName;
                user.Dob   = DOB;
                db.Users.Add(user);

                if (role == "Administrator")
                {
                    Administrators admin = new Administrators();
                    admin.UId = uID;
                    db.Administrators.Add(admin);
                }
                else if (role == "Professor")
                {
                    Professor pf = new Professor();
                    pf.UId     = uID;
                    pf.Subject = SubjectAbbrev;
                    db.Professor.Add(pf);
                }
                else if (role == "Student")
                {
                    Students st = new Students();
                    st.UId        = uID;
                    st.Subject    = SubjectAbbrev;
                    user.Students = st;
                    db.Students.Add(st);
                    System.Diagnostics.Debug.WriteLine("3");
                }
                db.SaveChanges();
            }

            return(uID);
        }
Exemplo n.º 15
0
 public void Insert(Administrators admin)
 {
     _ctx.administrator.Add(admin);
     _ctx.SaveChanges();
 }
Exemplo n.º 16
0
        /*******Begin code to modify********/

        /// <summary>
        /// Create a new user of the LMS with the specified information.
        /// Assigns the user a unique uID consisting of a 'u' followed by 7 digits.
        /// </summary>
        /// <param name="fName">First Name</param>
        /// <param name="lName">Last Name</param>
        /// <param name="DOB">Date of Birth</param>
        /// <param name="SubjectAbbrev">The department the user belongs to (professors and students only)</param>
        /// <param name="role">The user's role: one of "Administrator", "Professor", "Student"</param>
        /// <returns>A unique uID that is not be used by anyone else</returns>
        public string CreateNewUser(string fName, string lName, DateTime DOB, string SubjectAbbrev, string role)
        {
            string uID = "";

            switch (role)
            {
            case "Administrator":

                while (true)
                {
                    uID = "u" + RandomNumber(0, 9999999).ToString();

                    var query =
                        from a in db.Administrators
                        where a.UId == uID
                        select a;

                    if (!query.Any())
                    {
                        Administrators admin = new Administrators {
                            UId       = uID,
                            FirstName = fName,
                            LastName  = lName,
                            Dob       = DOB
                        };

                        db.Administrators.Add(admin);

                        try {
                            db.SaveChanges();
                        }
                        catch (Exception e) {
                            Console.WriteLine(e.Message);
                        }
                        break;
                    }
                }
                break;

            case "Professor":
                while (true)
                {
                    uID = "u" + RandomNumber(0, 9999999).ToString();

                    var query =
                        from a in db.Professors
                        where a.UId == uID
                        select a;

                    if (!query.Any())
                    {
                        Professors prof = new Professors {
                            UId        = uID,
                            FirstName  = fName,
                            LastName   = lName,
                            Dob        = DOB,
                            Department = SubjectAbbrev
                        };

                        db.Professors.Add(prof);

                        try {
                            db.SaveChanges();
                        }
                        catch (Exception e) {
                            Console.WriteLine(e.Message);
                        }
                        break;
                    }
                }
                break;

            case "Student":
                while (true)
                {
                    uID = "u" + RandomNumber(0, 9999999).ToString();

                    var query =
                        from a in db.Students
                        where a.UId == uID
                        select a;

                    if (!query.Any())
                    {
                        Students student = new Students {
                            UId       = uID,
                            FirstName = fName,
                            LastName  = lName,
                            Dob       = DOB,
                            Major     = SubjectAbbrev
                        };

                        db.Students.Add(student);

                        try {
                            db.SaveChanges();
                        }
                        catch (Exception e) {
                            Console.WriteLine(e.Message);
                        }
                        break;
                    }
                }
                break;

            default:
                Console.WriteLine("SOMETHING WENT WRONG");
                break;
            }

            return(uID);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Invitations    _invitation     = bInvitations.List().Where(m => m.Invitation_EmailId == txtEmailId.Text).FirstOrDefault();
                Administrators _administrators = bAdministrator.List().Where(m => m.EmailId == txtEmailId.Text).FirstOrDefault();
                if (_invitation == null && _administrators == null)
                {
                    Invitations invitations = new Invitations()
                    {
                        Store_Id               = Convert.ToInt32(ddlStore.SelectedValue),
                        Invitation_Code        = Guid.NewGuid().ToString(),
                        Invitation_EmailId     = txtEmailId.Text,
                        Invitation_CreatedDate = DateTime.Now,
                        Invitation_Status      = eStatus.Active.ToString(),
                        Role = ddlRole.Text,
                        Invitation_UpdatedDate = DateTime.Now,
                        Send_Activity_Mail     = (chkGetActivityMail.Checked) ? 1 : 0
                    };

                    invitations = bInvitations.Create(invitations);
                    ActivityHelper.Create("New Invitation", "New Invitation Created On " +
                                          DateTime.Now.ToString("D") + " Successfully, for EmailId " + invitations.Invitation_EmailId + ".",
                                          Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()));

                    if (String.IsNullOrEmpty(invitations.ErrorMessage))
                    {
                        if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
                        {
                            txtEmailId.Text        = "";
                            ddlRole.SelectedIndex  = 0;
                            ddlStore.SelectedIndex = 0;
                            string host = ConfigurationSettings.AppSettings["DomainUrl"].ToString();
                            host = host + "account/invitation.aspx?code=" + invitations.Invitation_Code + "&emailid=" + invitations.Invitation_EmailId;
                            string body = MailHelper.InvitationLink(host);
                            MailHelper.SendEmail(invitations.Invitation_EmailId, "Hurray!!! You Are Invited To Rachna Teracotta.", body, "Rachna Teracotta Invitation");
                            pnlErrorMessage.Attributes.Remove("class");
                            pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable";
                            pnlErrorMessage.Visible             = true;
                            lblMessage.Text = "Success! New Invitation Successfully.";
                        }
                        else
                        {
                            txtEmailId.Text        = "";
                            ddlRole.SelectedIndex  = 0;
                            ddlStore.SelectedIndex = 0;
                            pnlErrorMessage.Attributes.Remove("class");
                            pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable";
                            pnlErrorMessage.Visible             = true;
                            lblMessage.Text = "Success! New Invitation Successfully.";
                        }
                    }
                    else
                    {
                        pnlErrorMessage.Attributes.Remove("class");
                        pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                        pnlErrorMessage.Visible             = true;
                        lblMessage.Text = "Failed!" + invitations.ErrorMessage;
                    }

                    _invitation = null;
                    invitations = null;
                }
                else
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblMessage.Text = "Oops!! Invitation cannot be created, because entered email id already exists in the database.";
                }
            }
            catch (Exception ex)
            {
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = ex.InnerException.InnerException.Message;
            }
        }
Exemplo n.º 18
0
        public bool IsUserAdministrator(User u)
        {
            bool ad = Administrators.Contains(u);

            return(ad);
        }
Exemplo n.º 19
0
 /// <summary>Find out if a princpial has admin access.</summary>
 /// <param name="user">The princpial to check.</param>
 /// <returns>A boolean indicating whether the principal has admin access.</returns>
 public virtual bool IsAdmin(IPrincipal user)
 {
     return(Administrators.Contains(user));
 }
Exemplo n.º 20
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string _res = string.Empty;

            using (var ctx = new RachnaDBContext())
            {
                int   productId     = Convert.ToInt32(hdnOrderId.Value);
                Order _productOrder = new Order();
                _productOrder = ctx.Orders.ToList().Where(m => m.Order_Id == productId).FirstOrDefault();

                if (_productOrder.Order_Status != eOrderStatus.Rejected.ToString())
                {
                    if (_productOrder.Order_Status != ddlSorderStatus.Text)
                    {
                        if (_productOrder.Order_Status ==
                            eOrderStatus.Approved.ToString() &&
                            (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() ||
                             ddlSorderStatus.Text == eOrderStatus.Approved.ToString()))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true);
                        }
                        else if (_productOrder.Order_Status ==
                                 eOrderStatus.Packed.ToString() &&
                                 (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Approved.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Packed.ToString()))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true);
                        }
                        else if (_productOrder.Order_Status == eOrderStatus.Shipped.ToString() &&
                                 (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Approved.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Packed.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Shipped.ToString()))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true);
                        }
                        else if (_productOrder.Order_Status == eOrderStatus.Delevery.ToString() &&
                                 (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Approved.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Packed.ToString() ||
                                  ddlSorderStatus.Text == eOrderStatus.Shipped.ToString()))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "alert('update failed because, order status is lower then current');", true);
                        }
                        else
                        {
                            _productOrder.Order_Status     = ddlSorderStatus.Text;
                            ctx.Entry(_productOrder).State = EntityState.Modified;
                            ctx.SaveChanges();

                            var            adminId      = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()]);
                            Administrators _adm         = ctx.Administrator.Where(m => m.Administrators_Id == adminId).FirstOrDefault();
                            OrderHistory   _orderCancel = new OrderHistory();
                            _orderCancel.Order_Id = Convert.ToInt32(hdnOrderId.Value);
                            _orderCancel.OrderHistory_Description = txtOrderDescription.Text;
                            _orderCancel.OrderHistory_Status      = ddlSorderStatus.Text;
                            _orderCancel.OrderHistory_CreatedDate = DateTime.Now;
                            _orderCancel.OrderHistory_UpdatedDate = DateTime.Now;
                            _orderCancel.Administrators_Id        = _adm.Administrators_Id;
                            _orderCancel.Store_Id = _adm.Store_Id;

                            ctx.OrderHistories.Add(_orderCancel);
                            ctx.SaveChanges();

                            if (pnlDeleveryTeam.Visible == true)
                            {
                                OrderDelivery OrderDelivery = new OrderDelivery()
                                {
                                    Order_Id          = _productOrder.Order_Id,
                                    Administrators_Id = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()),
                                    TeamId            = Convert.ToInt32(ddlDelieveryTeam.SelectedValue.ToString()),
                                    Comment           = txtOrderDescription.Text,
                                    Status            = eOrderDeliveryStatus.InTransist.ToString(),
                                    Store_Id          = _productOrder.Store_Id,
                                    Customer_Id       = _productOrder.Customer_Id,
                                    DateCreated       = DateTime.Now,
                                    DateUpdated       = DateTime.Now
                                };

                                ctx.OrderDelivery.Add(OrderDelivery);
                                ctx.SaveChanges();
                            }

                            Customers _cust = ctx.Customer.ToList().Where(m => m.Customer_Id == Convert.ToInt32(_productOrder.Customer_Id)).FirstOrDefault();

                            string productUrl = "http://rachnateracotta.com/product/index?id=" + _productOrder.Product_Id;
                            _res = _res + "<tr style='border: 1px solid black;'><td style='border: 1px solid black;'><img src='" + _productOrder.Product_Banner + "' width='100' height='100'/></td>"
                                   + "<td style='border: 1px solid black;'><a href='" + productUrl + "'>" + _productOrder.Product_Title + "</a></td><td style='border: 1px solid black;'> Total Quantity :" + _productOrder.Order_Qty + " </td><td style='border: 1px solid black;'> " + _productOrder.Order_Price + " </td></tr>";

                            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
                            {
                                string host = string.Empty;
                                host = "<table style='width:100%'>" + _res + "</ table >";
                                string body = MailHelper.CustomerOrderProcessed(host, (_cust.Customers_FullName), txtOrderDescription.Text);
                                MailHelper.SendEmail(_cust.Customers_EmailId, "Success!!! " + txtOrderDescription.Text + " Rachna Teracotta Estore.", body, "Rachna Teracotta Order" + txtOrderDescription.Text);
                            }

                            Response.Redirect("/administration/salesmanagement/vorderdetail.aspx?orderId=" + hdnOrderId.Value + "&requesttype=view-order-detail.html");
                        }
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is same as current.', { title: 'Failed!! ' });", true);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is not valid.', { title: 'Failed!! ' });", true);
                }
            }
        }