コード例 #1
0
        public static Cart CreateCart()
        {
            using (ArtShopEntities db = new ArtShopEntities())
            {
                Cart newCart = new Cart();
                newCart.user_id = (Guid)getLoginUser().ProviderUserKey;
                if (newCart.user_id == null)
                {
                    return(null);
                }
                if (db.Carts.Count() == 0)
                {
                    newCart.id = 1;
                }
                else
                {
                    newCart.id = db.Carts.OrderByDescending(u => u.id).FirstOrDefault().id + 1;
                }
                try
                {
                    db.Carts.Add(newCart);
                    db.SaveChanges();
                    return(newCart);

                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.SUCCESS_TYPE,
                                                          "Hello " + Functions.getLoginUser().UserName + " !!",
                                                          "Hi, new user you can click \"Shopping Cart\" navigation at the top to check you cart!!"));
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
コード例 #2
0
    public void AddPageNode()
    {
        string      sql = "SELECT Pages.parent_id FROM [Pages] Group By Pages.parent_id Order By Pages.parent_id";
        string      sql2 = "SELECT [Pages].Id  FROM [Pages] WHERE [Pages].parent_id = -1";
        List <int>  parent_id, id = new List <int>();
        Page        page;
        List <Page> pages;
        SiteMapNode siteMapNode, detailsNode;

        using (ArtShopEntities db = new ArtShopEntities())
        {
            parent_id = db.Database.SqlQuery <int>(sql).ToList();
            id        = db.Database.SqlQuery <int>(sql2).ToList();
            foreach (int x in id)
            {
                page        = db.Pages.Find(x);
                pages       = db.Pages.SqlQuery("SELECT * FROM [Pages] WHERE [Pages].parent_id = " + x).ToList();
                siteMapNode = new SiteMapNode(this, x + "key1", page.file_name, page.title, page.description);
                AddNode(siteMapNode, parentNode);
                if (pages.Count > 0)
                {
                    foreach (Page page1 in pages)
                    {
                        detailsNode = new SiteMapNode(this, page1.Id + "key2", page1.file_name, page1.title, page1.description);
                        AddNode(detailsNode, siteMapNode);
                    }
                }
            }
        }
    }
コード例 #3
0
        private void deleterowdata(int cart_id, int art_id)
        {
            try
            {
                using (ArtShopEntities db = new ArtShopEntities())
                {
                    CartDetail c = db.CartDetails.Find(cart_id, art_id);
                    db.CartDetails.Remove(c);
                    db.SaveChanges();

                    Functions.EnqueueNewNotifications(new Notifications(
                                                          2,
                                                          Notifications.SUCCESS_TYPE,
                                                          "Deleted Sucessful!!",
                                                          "you have remove item form your cart !!"));
                }
            }
            catch (Exception e)
            {
                Functions.EnqueueNewNotifications(new Notifications(
                                                      2,
                                                      Notifications.ERROR_TYPE,
                                                      "Deleted Failed!!",
                                                      "you have following exception : " + e.Message + " !!"));
            }
        }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         setValidatorAndVisible(true);
         if (editMode)
         {
             using (ArtShopEntities db = new ArtShopEntities())
             {
                 try
                 {
                     Art art = db.Arts.Find(int.Parse(artId));
                     this.putData(art);
                 }
                 catch (Exception ex)
                 {
                     Functions.EnqueueNewNotifications(new Notifications(
                                                           Notifications.ERROR_TYPE,
                                                           "Art not found!!",
                                                           "you have following exception : " + ex.Message + " !!"));
                 }
             }
             btnSubmit.Text = "Updates Art";
         }
     }
 }
コード例 #5
0
        protected List <Art> OrderDetailsDataTable(Guid order_id)
        {
            string sql = "SELECT Art.art_id as id, Art.[image] as [image], " +
                         "Art.date as date, " +
                         "[UserExtension].first_name + ' ' + [UserExtension].last_name as [description], " +
                         "Art.price as price, [PaymentDetails].product_quantity as artist_id, " +
                         "Art.[title] as [title] " +
                         "FROM [Art], [PaymentDetails], [UserExtension] " +
                         "WHERE PaymentDetails.payment_id = @order_id AND " +
                         "Art.artist_id = [UserExtension].[UserId] AND " +
                         "art_id = PaymentDetails.art_id";

            using (ArtShopEntities db = new ArtShopEntities())
            {
                try
                {
                    var da = db.Arts.SqlQuery(sql, new SqlParameter("@order_id", order_id));
                    return(da.ToList());
                }
                catch (Exception ex)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "2 Rocord searching!!",
                                                          "<strong>You had occur an error in RepeaterOrder_ItemDataBound!!!</strong> " + ex.Message + "<br />"));
                }
            }
            return(null);
        }
コード例 #6
0
 protected string convert_user_role(Guid user_r)
 {
     using (ArtShopEntities db = new ArtShopEntities())
     {
         return(db.PaymentStatus.Find(user_r).name);
     }
 }
コード例 #7
0
        protected void confirmPayment(object sender, EventArgs e)
        {
            using (ArtShopEntities db = new ArtShopEntities())
            {
                bank.amount            -= (decimal)payments.total_pay;
                payments.payment_status = Guid.Parse("c595596d-8980-4138-bc20-a91056e1b1ce");
                payments.payment_method = Guid.Parse("1c98a7a8-6449-4ca4-be81-8b21f1cc12e0");
                payments.payment_meta   = bank.bank_account;
                payments.customer_paid  = payments.total_pay;
                payments.payment_date   = DateTime.Now;

                db.Payments.AddOrUpdate(payments);
                db.PublicBanks.AddOrUpdate(bank);

                try
                {
                    db.SaveChanges();
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.SUCCESS_TYPE,
                                                          "Payment sucessfull!!",
                                                          "you have complete the payment using following account: " + bank.bank_account + ""));
                    Functions.sendPaymentMail(payments);
                }
                catch (Exception ex)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Payment Failed!!",
                                                          "you have following exception : " + ex.Message + " !!"));
                }
            }
        }
コード例 #8
0
        private void retriveDataAndAnalysis(ArtShopEntities db)
        {
            IQueryable <vw_customer_cart2> x = db.vw_customer_cart2.Where(s => s.user_id == id);

            vw_customer_cart2[] y = x.ToArray();
            Painting            paint;

            for (int i = 0; i < x.Count(); i++)
            {
                if (y[i].@virtual)
                {
                    if (y[i].@checked ?? false)
                    {
                        total += Convert.ToDouble(y[i].price);
                        checkedCount++;
                    }
                }
                else
                {
                    if (y[i].@checked ?? false)
                    {
                        checkedCount++;
                        total += (Convert.ToDouble(y[i].price) * (double)y[i].availability);
                    }
                }
            }
            totalCount              = x.Count();
            this.lblCount.Text      = checkedCount + "";
            this.lblTotal.Text      = totalCount + "";
            this.lblTotalPrice.Text = "RM " + total.ToString("0.00");
        }
コード例 #9
0
        public void ProcessRequest(HttpContext context)
        {
            string guid     = context.Request.QueryString["guid"].ToString();
            string _default = context.Request.QueryString["default"].ToString();

            byte[] data = null;
            Artist artist;

            using (ArtShopEntities db = new ArtShopEntities())
            {
                artist = db.Artists.Find(Guid.Parse(guid));
                data   = artist.signature;
            }
            try
            {
                if (data != null)
                {
                    context.Response.BinaryWrite(data);
                }
                else
                {
                    context.Response.BinaryWrite(
                        Functions.ImmageAssetToByte(getSelectionImage(_default))
                        );
                }
            }
            catch
            {
                context.Response.BinaryWrite(
                    Functions.ImmageAssetToByte(getSelectionImage(_default))
                    );
            }
        }
コード例 #10
0
        protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            var chk         = (CheckBox)sender;
            var CommandName = chk.Attributes["CommandName"];
            int id          = int.Parse(CommandName);

            using (ArtShopEntities db = new ArtShopEntities())
            {
                try
                {
                    CartDetail cd = db.Carts.Find(cart_id).CartDetails.Where(c => c.art_id == id).FirstOrDefault();
                    cd.@checked = chk.Checked;
                    db.CartDetails.AddOrUpdate(cd);
                    db.SaveChanges();

                    total        = 0;
                    totalCount   = 0;
                    checkedCount = 0;
                    if (check_cart_count(db))
                    {
                        retriveDataAndAnalysis(db);
                    }
                }
                catch (Exception ex)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Deleted Failed!!",
                                                          "you have following exception : " + ex.Message + " !!"));
                }
            }
            Repeater2.DataBind();
        }
コード例 #11
0
        protected void Delete(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            int    x   = int.Parse(btn.CommandArgument);

            using (ArtShopEntities db = new ArtShopEntities())
            {
                Art art = db.Arts.Find(x);
                if (art != null)
                {
                    try {
                        db.Arts.Remove(art);
                        db.SaveChanges();
                        Functions.EnqueueNewNotifications(new Notifications(
                                                              Notifications.SUCCESS_TYPE,
                                                              "Deleted Sucessful!!",
                                                              "you have deleted sucessful !!"));
                    }
                    catch (Exception ex)
                    {
                        Functions.EnqueueNewNotifications(new Notifications(
                                                              Notifications.ERROR_TYPE,
                                                              "Deleted Failed!!",
                                                              "you have following exception : " + ex.Message + " !!"));
                    }
                }
                else
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Deleted Failed!!",
                                                          "Art not founds !!"));
                }
            }
        }
コード例 #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (ArtShopEntities db = new ArtShopEntities())
     {
         loginUser = (Guid)Functions.getLoginUser().ProviderUserKey;
         putData(db.aspnet_Users.Find(loginUser));
     }
 }
コード例 #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (ArtShopEntities db = new ArtShopEntities())
     {
         art = db.Arts.Find(int.Parse(Request.QueryString["id"]));
         quantity.Enabled = !art.@virtual;
     }
 }
コード例 #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (ArtShopEntities db = new ArtShopEntities())
     {
         List <Art> ts = db.Arts.ToList();
         Repeater1.DataSource = ts.GetRange(0, ts.Count >= 5?5:ts.Count);
         Repeater1.DataBind();
     }
 }
コード例 #15
0
        protected Art getData(ArtShopEntities db)
        {
            Art art = new Art();

            //  Art atr2;
            art.title       = this.TitleText.Text;
            art.description = this.Discription.Text;
            art.date        = this.DateCreation.Text;
            art.price       = decimal.Parse(this.Price.Text);
            art.artist_id   = (Guid)Functions.getLoginUser().ProviderUserKey;
            JArray data     = (JArray)JsonConvert.DeserializeObject(realCatergory.Value);
            string fileName = art.id + "-" + art.title.Replace(" ", "-");
            string exe      = new FileInfo(xFileUpload.PostedFile.FileName).Extension;

            art.image    = "/assets/image/Art/" + fileName + exe;
            art.@virtual = Virtual.Checked;
            xFileUpload.SaveAs(Server.MapPath("~/assets/image/Art/") + fileName + exe);

            for (int i = 0; i < data.Count; i++)
            {
                art.Categories.Add(db.Categories.Find(data[i].ToObject <int>()));
            }

            if (!Virtual.Checked)
            {
                art.Categories.Add(db.Categories.Find(7));
            }
            else
            {
                art.Categories.Add(db.Categories.Find(8));
            }

            if (!Virtual.Checked)
            {
                Painting p = new Painting();
                p.art_id    = art.id;
                p.quantity  = int.Parse(this.txbQuantity.Text);
                p.weight_g  = int.Parse(this.txbWeight.Text);
                p.lenght_mm = int.Parse(this.txbLL.Text);
                p.width_mm  = int.Parse(this.txbWW.Text);
                p.height_mm = int.Parse(this.txbHH.Text);
                p.Address   = db.Addresses.Find(Guid.Parse(ddlAddress.SelectedValue));

                art.Painting = p;
            }

            if (!this.editMode)
            {
                art.id = db.Arts.OrderByDescending(u => u.id).FirstOrDefault().id + 1;;
            }
            else
            {
                art.id = int.Parse(artId);
            }
            return(art);
        }
コード例 #16
0
        protected string setCatergory(int cat_id)
        {
            string r = "";

            using (ArtShopEntities db = new ArtShopEntities())
            {
                r = db.Categories.Find(cat_id).name;
            }
            return(r);
        }
コード例 #17
0
 protected void Page_Init(object sender, EventArgs e)
 {
     SqlDataSource1.SelectParameters.Add("UserId", Functions.getLoginUser().ProviderUserKey.ToString());
     using (ArtShopEntities db = new ArtShopEntities())
     {
         allcats = new List <CategoryCopy>();
         int p_level = Roles.GetRolesForUser().Contains("Administrator") ? 1 : 0;
         db.Categories.Where(c => c.enable == true && c.permission_level <= p_level)
         .ToList().ForEach(c => allcats.Add(new CategoryCopy(c)));
         allCatStr = JsonConvert.SerializeObject(allcats);
     }
     artId    = Request.QueryString["id"];
     editMode = artId != null;
 }
コード例 #18
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = this.CardName.Text;
            string pass = this.CardPass.Text;

            using (ArtShopEntities db = new ArtShopEntities())
            {
                PublicBank    database = db.PublicBanks.Find(name);
                modal.Payment payments = db.Payments.Find(paymentId);
                if (database == null)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Invalid card number!!",
                                                          "Wrong card numbers"));
                    return;
                }
                if (database.bank_username != name)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Unassessable!!",
                                                          "Username not match"));
                    return;
                }
                if (database.password != pass)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Unassessable!!",
                                                          "Password not match"));
                    return;
                }
                if ((double)database.amount < payments.total_pay)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Not enought amount!!",
                                                          "Your card is only remain " + database.amount));
                    return;
                }
                Functions.EnqueueNewNotifications(new Notifications(
                                                      Notifications.SUCCESS_TYPE,
                                                      "Login sucessfull!!",
                                                      "Welcome, " + database.bank_username));

                Session[Constant.ACCOUNT_SESSION] = database.bank_account;
                Response.Redirect("~/pages/Payment/PublicBank.aspx?id=" + this.paymentId);
            }
        }
コード例 #19
0
        private static void checkAddressExcite(string latlng_text, out bool created, out float lat, out float lng)
        {
            created = false;
            dynamic latlng = JsonConvert.DeserializeObject(latlng_text);

            lat = latlng["lat"];
            lng = latlng["lng"];
            using (ArtShopEntities db = new ArtShopEntities())
            {
                Address[] addresss = db.Addresses.ToArray();
                for (int i = 0; i < addresss.Length; i++)
                {
                    if ((addresss[i].latitude == lat && addresss[i].longitude == lng))
                    {
                        created = true;
                        if (db.UserAddresses.Find(Functions.getLoginUser().ProviderUserKey, addresss[i].id) != null)
                        {
                            Functions.EnqueueNewNotifications(new Notifications(
                                                                  Notifications.ERROR_TYPE,
                                                                  "Address excites",
                                                                  "This address is been added to yours preference"));
                        }
                        else
                        {
                            try
                            {
                                UserAddress userAddress = new UserAddress();
                                userAddress.address_id = addresss[i].id;
                                userAddress.UserId     = (Guid)Functions.getLoginUser().ProviderUserKey;

                                db.UserExtensions.Find(Functions.getLoginUser().ProviderUserKey).UserAddresses.Add(userAddress);
                                db.SaveChanges();
                                Functions.EnqueueNewNotifications(new Notifications(
                                                                      Notifications.SUCCESS_TYPE,
                                                                      "Adding successful",
                                                                      "Your new reference address is updates to your profiles"));
                            }
                            catch (Exception ex)
                            {
                                Functions.EnqueueNewNotifications(new Notifications(
                                                                      Notifications.ERROR_TYPE,
                                                                      "Unknows error founds 2",
                                                                      "Error : " + ex.Message));
                            }
                        }
                    }
                }
            }
        }
コード例 #20
0
        private bool check_cart_count(ArtShopEntities db)
        {
            Cart cart_record = db.Carts.Where(s => s.user_id == id).FirstOrDefault();

            if (cart_record != null ? cart_record.CartDetails.Count > 0 : false)
            {
                cart_id             = cart_record.id;
                GotCart.Visible     = true;
                NoCartFound.Visible = false;
                return(true);
            }
            else
            {
                NoCartFound.Visible = true;
                GotCart.Visible     = false;
                return(false);
            }
        }
コード例 #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            param_id            = Request.QueryString["id"];
            param_type          = Request.QueryString["type"];
            display_in_map      = (param_type == "show" || param_type == "edit");
            procide_map.Enabled = !display_in_map;
            if (display_in_map)
            {
                using (ArtShopEntities db = new ArtShopEntities())
                {
                    address = db.Addresses.Find(Guid.Parse(param_id));
                }
                procide_map.Text = "View Only";
            }
            if (param_type == "remove")
            {
                using (ArtShopEntities db = new ArtShopEntities())
                {
                    try
                    {
                        Address     add         = db.Addresses.Find(Guid.Parse(param_id));
                        UserAddress userAddress = new UserAddress();
                        userAddress.UserId     = (Guid)Functions.getLoginUser().ProviderUserKey;
                        userAddress.address_id = add.id;

                        userAddress = db.UserAddresses.Find(Functions.getLoginUser().ProviderUserKey, add.id);
                        db.UserAddresses.Remove(userAddress);
                        db.SaveChanges();
                        Functions.EnqueueNewNotifications(new Notifications(
                                                              Notifications.SUCCESS_TYPE,
                                                              "Address removed !!",
                                                              "The reference address is removed form your prefrence list."));
                    }
                    catch (Exception ex)
                    {
                        Functions.EnqueueNewNotifications(new Notifications(
                                                              Notifications.ERROR_TYPE,
                                                              "Unknows error founds",
                                                              "Error : " + ex.Message));
                    }
                }
                Response.Redirect("MyAccount.aspx?");
            }
        }
コード例 #22
0
        protected void updatesData(ArtShopEntities db)
        {
            UserExtension     ux = db.UserExtensions.Find(loginUser);
            aspnet_Membership am = db.aspnet_Membership.Find(loginUser);

            ux.first_name = this.firstName.Text;
            ux.last_name  = this.lastName.Text;
            if (this.radioMale.Checked)
            {
                ux.gender = "Male";
            }
            else
            {
                ux.gender = "Female";
            }

            db.aspnet_Membership.AddOrUpdate(am);
            db.UserExtensions.AddOrUpdate(ux);
        }
コード例 #23
0
        public static bool checkValidPayment(String param)
        {
            Guid id;

            if (param == null)
            {
                HttpContext.Current.Response.Redirect("~/pages/Payment/PaymentInvalid.aspx");
                return(false);
            }
            id = Guid.Parse(param);
            if (id == null)
            {
                HttpContext.Current.Response.Redirect("~/pages/Payment/PaymentInvalid.aspx");
                return(false);
            }
            using (ArtShopEntities db = new ArtShopEntities())
            {
                Payment p = db.Payments.Find(id);
                if (p == null)
                {
                    HttpContext.Current.Response.Redirect("~/pages/Payment/PaymentInvalid.aspx");
                    return(false);
                }
                switch (p.PaymentStatu.id.ToString())
                {
                case "80e85ebb-7401-45be-8080-4d16df2177bf":
                    return(true);

                    break;    //Fail

                case "20bd9f32-b531-4b7f-a89a-80babe9aa707":
                    return(true);

                    break;    //Padding

                default:
                    HttpContext.Current.Response.Redirect("~/pages/Payment/PaymentInvalid.aspx");
                    return(false);

                    break;
                }
            }
        }
コード例 #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Functions.checkValidPayment(Request.QueryString["id"]);
            paymentId = Guid.Parse(Request.QueryString["id"]);
            if (Session[Constant.ACCOUNT_SESSION] == null)
            {
                Response.Redirect("~");
                return;
            }

            using (ArtShopEntities db = new ArtShopEntities())
            {
                bank          = db.PublicBanks.Find(Session[Constant.ACCOUNT_SESSION]);
                payments      = db.Payments.Find(paymentId);
                CardName.Text = bank.bank_account;
                CardPass.Text = DateTime.Now.ToString();
                Label1.Text   = payments.total_pay.ToString();
            }
        }
コード例 #25
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     using (ArtShopEntities db = new ArtShopEntities())
     {
         try
         {
             updatesData(db);
             db.SaveChanges();
             Functions.EnqueueNewNotifications(new Notifications(
                                                   Notifications.SUCCESS_TYPE,
                                                   "Updates completed", "Your informations is up to date"));
         }
         catch (Exception ex)
         {
             Functions.EnqueueNewNotifications(new Notifications(
                                                   Notifications.ERROR_TYPE,
                                                   "Updates fail", ex.Message));
         }
     }
 }
コード例 #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id = (Guid)Functions.getLoginUser().ProviderUserKey;
            if (!Page.IsPostBack)
            {
                SqlDataSource1.SelectParameters.Add("user_id", DbType.Guid, id.ToString());
                SqlDataSource2.SelectParameters.Add("user_id", DbType.Guid, id.ToString());
            }
            using (ArtShopEntities db = new ArtShopEntities())
            {
                total        = 0;
                totalCount   = 0;
                checkedCount = 0;
                if (check_cart_count(db))
                {
                    retriveDataAndAnalysis(db);
                }

                //totalprice.Text = "Total price : RM" + total.ToString();
            }
        }
コード例 #27
0
    public void AddPaymentNode()
    {
        SiteMapNode siteMapNode = new SiteMapNode(this, "Haha-1", "Payment Node", "Payment", "Procide payment");

        AddNode(siteMapNode, parentNode);
        List <Payment> orders;

        using (ArtShopEntities db = new ArtShopEntities())
        {
            orders = db.Payments.SqlQuery("SELECT * FROM [Payment]").ToList();
            foreach (Payment pay in orders)
            {
                AddNode(
                    new SiteMapNode(this,
                                    pay.id + "-payment",
                                    PAGE_DIR + "Payment.aspx?order=" + pay.id.ToString(),
                                    pay.id.ToString(),
                                    pay.id.ToString()),
                    siteMapNode);
            }
        }
    }
コード例 #28
0
    public void AddProductNode()
    {
        SiteMapNode siteMapNode = new SiteMapNode(this, "Haha-2", "Product Node", "Product", "The Art Sales.com sell");

        AddNode(siteMapNode, parentNode);
        List <Art> arts;

        using (ArtShopEntities db = new ArtShopEntities())
        {
            arts = db.Arts.SqlQuery("SELECT * FROM [Art]").ToList();
            foreach (Art art in arts)
            {
                AddNode(
                    new SiteMapNode(this,
                                    art.id + "-art-products",
                                    PAGE_DIR + "main/ArtShop/ArtShop_Cust_Details.aspx?id=" +
                                    art.id,
                                    art.title,
                                    art.title),
                    siteMapNode);
            }
        }
    }
コード例 #29
0
 protected void updates()
 {
     using (ArtShopEntities db = new ArtShopEntities())
     {
         Art art = getData(db);
         try
         {
             db.Arts.AddOrUpdate(art);
             db.SaveChanges();
             Functions.EnqueueNewNotifications(new Notifications(
                                                   Notifications.SUCCESS_TYPE,
                                                   "Update completed",
                                                   "you have done the updates !!"));
         }
         catch (Exception ex)
         {
             Functions.EnqueueNewNotifications(new Notifications(
                                                   Notifications.ERROR_TYPE,
                                                   "Update Failed!!",
                                                   "you have following exception : " + ex.Message + " !!"));
         }
     }
     Response.Redirect("ReadUpdateDeleteArt.aspx");
 }
コード例 #30
0
        public void addAddress()
        {
            string address_text = this.form_address.Value;
            string latlng_text  = this.form_latlng.Value;

            Console.Out.WriteLine("procide_map_Click");
            if (latlng_text.Length <= 0)
            {
                Functions.EnqueueNewNotifications(new Notifications(
                                                      Notifications.ERROR_TYPE,
                                                      "No address selected",
                                                      "Please select a address to procide"));
                return;
            }

            bool  created;
            float lat, lng;

            checkAddressExcite(latlng_text, out created, out lat, out lng);

            if (created)
            {
                return;
            }

            dynamic result         = MapApiProvider.GetReverseGeocoding(lat, lng);
            JArray  resultsDetails = result["results"];

            if (result["status"] == "OK" ? resultsDetails.Count > 0 : false)
            {
                Address address = decodeGeoAddress(resultsDetails);

                using (ArtShopEntities db = new ArtShopEntities())
                {
                    Address old_address = db.Addresses.Where(
                        q => q.street == address.street &&
                        q.city == address.city &&
                        q.state == address.state &&
                        q.poscode == address.poscode &&
                        q.country == address.country
                        ).FirstOrDefault();
                    if (old_address != null ? db.UserAddresses.Find(Functions.getLoginUser().ProviderUserKey, old_address.id) != null: false)
                    {
                        Functions.EnqueueNewNotifications(new Notifications(
                                                              Notifications.ERROR_TYPE,
                                                              "Address excites",
                                                              "This address is been added to yours preference"));
                    }
                    else
                    {
                        try
                        {
                            UserAddress userAddress = new UserAddress();
                            userAddress.UserId = (Guid)Functions.getLoginUser().ProviderUserKey;
                            address.id         = Guid.NewGuid();
                            if (old_address != null)
                            {
                                userAddress.address_id = old_address.id;
                            }
                            else
                            {
                                userAddress.Address = address;
                            }
                            db.UserExtensions.Find(Functions.getLoginUser().ProviderUserKey).UserAddresses.Add(userAddress);
                            db.SaveChanges();
                            Functions.EnqueueNewNotifications(new Notifications(
                                                                  Notifications.SUCCESS_TYPE,
                                                                  "Adding successfu",
                                                                  "Your new reference address is updates to your profiles"));
                        }
                        catch (Exception ex)
                        {
                            Functions.EnqueueNewNotifications(new Notifications(
                                                                  Notifications.ERROR_TYPE,
                                                                  "Unknows error founds 1",
                                                                  "Error : " + ex.Message));
                        }
                    }
                }
            }
            else
            {
                Functions.EnqueueNewNotifications(new Notifications(
                                                      Notifications.ERROR_TYPE,
                                                      "Google Map API Error!",
                                                      result["status"] + ": " + result["error_message"] + " !!"));
            }
        }