Beispiel #1
0
 /// <summary>
 /// JSON data format of {"category" : "1", "data" : "xxx"}
 /// where xxx depends of category:
 /// NewOpenJob - job id, app should regconize and go to the open job page (partner)
 /// OrderCreated - order id, app should regconize and go to order status page (consumer)
 /// OrderStatusUpdate - order id, app should regconize and go to order status page (consumer)
 /// RatingUpdate - job id, app should open the job details page on the delivery (partner)
 /// JobAssigned - job id, app should open the job details page on the delivery (driver)
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public static object ConstructExtraData(ECategories category, string data)
 {
     return(new ExtraData()
     {
         category = ((int)category).ToString(), data = data
     });
 }
Beispiel #2
0
        /// <summary>
        /// Devuelve todas las categorias
        /// </summary>
        /// <returns></returns>
        public List <ECategories> GetAll()
        {
            List <ECategories> res = new List <ECategories>();

            try
            {
                using (var db = new DataAccess.Models.NewsDBContext())
                {
                    var query = (from x in db.Categories select x).ToList();
                    if (query.Any())
                    {
                        foreach (var i in query)
                        {
                            ECategories e = new ECategories();
                            e.IdCategory  = i.IdCategory;
                            e.Name        = i.Name;
                            e.Description = i.Description;
                            res.Add(e);
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(res);
        }
Beispiel #3
0
    public string UpdateECategories(string companyCode, string json)
    {
        clsDataAccessor dataAccessor = new clsDataAccessor();

        dataAccessor.connectionstring = dataAccessor.getConnectionString_Vapt(dataAccessor, companyCode);

        ECategories EC         = new ECategories();
        var         serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

        string response = "";

        /*  json = @"{
         * ""cat_id"":""12122222"",
         * ""cat_code"":""Testing181212"",
         * ""cat_descp"":""test"",
         * ""cat_otherlanguage"":"""",
         * ""cat_createdate"":""2019-11-07"",
         * }";
         *
         * passing value :
         *  {"eCategory":[{"cat_id":"1","cat_code":"Bird’s Nest & Snow Jelly","cat_descp":"Bird’s Nest & Snow Jelly","cat_otherlanguage":"","cat_createdate":"2019-11-13"},
         * {"cat_id":"2","cat_code":"Dried Bird’s Nest","cat_descp":"Dried Bird’s Nest","cat_otherlanguage":"","cat_createdate":"2019-11-13"}]}
         */
        try
        {
            EC = serializer.Deserialize <ECategories>(json);
        }
        catch (Exception ex)
        {
            return(ex.ToString());
        }
        response = dataAccessor.updateECateoriesData(EC);

        return(response);
    }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            if (Request.QueryString["ID"] != null)
            {
                ECategories category = new ECategories();
                category.ID = int.Parse(Request.QueryString["ID"]);
                bool sonuc = BLLCategories.Delete(category);
                if (sonuc)
                {
                    Response.Write("<script>alert('Harika! Silindi!')</script>");
                }
                else
                {
                    Response.Write("<script>alert('Hay Aksi! Silinemedi!')</script>");
                }
            }

            rptKategoriler.DataSource = BLLCategories.GetAll();
            rptKategoriler.DataBind();

            if (Request.QueryString["scs"] != null)
            {
                int scsID = Convert.ToInt32(Request.QueryString["scs"].ToString());
                if (scsID == 1)
                {
                    Response.Write("<script>alert('Harika! Güncellendi!');</script>");
                }
            }
        }
Beispiel #5
0
        public IActionResult Update([FromBody] ECategories e)
        {
            var res = daCategories.Update(e);

            if (res)
            {
                return(Ok());
            }
            return(BadRequest());
        }
        public static void Delete(ECategories category)
        {
            SqlCommand cmd = new SqlCommand("spCategories_Delete", Baglanti.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("categoryID", category.ID);
            Baglanti.conn.Open();
            cmd.ExecuteNonQuery();
            Baglanti.conn.Close();
        }
Beispiel #7
0
        public void Create()
        {
            DA.Business.DaCategories _da = new DA.Business.DaCategories();
            ECategories e = new ECategories();

            e.Name        = "Categoria Prueba";
            e.Description = "Descri Prueba";
            var res = _da.Create(e);

            Assert.IsNotNull(res);
        }
        public static void InsertNewCategory(ECategories category)
        {
            SqlCommand cmd = new SqlCommand("spCategories_Insert", Baglanti.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Name", category.Name);
            cmd.Parameters.AddWithValue("@Description", category.Description);

            Baglanti.conn.Open();
            cmd.ExecuteNonQuery();
            Baglanti.conn.Close();
        }
Beispiel #9
0
 public static bool InsertNewCategory(ECategories category)
 {
     if (category.Name == "")
     {
         return(false);
     }
     else
     {
         DALCategories.InsertNewCategory(category);
         return(true);
     }
 }
Beispiel #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int categoryID = Convert.ToInt32(Request.QueryString["categoryID"].ToString());

            ECategories category = new ECategories();

            category = BLLCategories.GetIdOnly(categoryID);
            if (!IsPostBack)
            {
                txtTurAdi.Text        = category.Name;
                TxtTurAciklamasi.Text = category.Description;
            }
        }
Beispiel #11
0
 public IActionResult Create([FromBody] ECategories e)
 {
     if (ModelState.IsValid)
     {
         var res = daCategories.Create(e);
         if (res != 0)
         {
             return(new CreatedAtRouteResult("CreatedCategory", new { id = res }, e));
         }
         return(BadRequest("Error en la creacion"));
     }
     return(BadRequest(ModelState));
 }
        public ECategories Get(int id)
        {
            ECategories res = new ECategories();

            try
            {
                var q = (from x in db.Categories select x).FirstOrDefault();
                res.Description = q.Description;
                res.Name        = q.Name;
            }
            catch (Exception)
            {
                throw;
            }
            return(res);
        }
        public bool Update(ECategories e)
        {
            bool res = false;

            try
            {
                var query = (from x in db.Categories where x.IdCategory == e.IdCategory select x).FirstOrDefault();
                query.Name        = e.Name;
                query.Description = e.Description;
                db.Categories.Update(query);
                db.SaveChanges();
                res = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(res);
        }
        public int Create(ECategories e)
        {
            int res = 0;

            try
            {
                DataAccess.Models.Categories obj = new Categories();
                obj.Name        = e.Name;
                obj.Description = e.Description;
                db.Categories.Add(obj);
                db.SaveChanges();
                res = obj.IdCategory;
            }
            catch (Exception)
            {
                throw;
            }
            return(res);
        }
        public static List <ECategories> GetAll()
        {
            SqlCommand cmd = new SqlCommand("spCategories_GetAll", Baglanti.conn);

            Baglanti.conn.Open();
            SqlDataReader      dr     = cmd.ExecuteReader();
            List <ECategories> cliste = new List <ECategories>();

            while (dr.Read())
            {
                ECategories c = new ECategories();
                c.ID          = Convert.ToInt32(dr["ID"]);
                c.Name        = dr["Name"].ToString();
                c.Description = dr["Description"].ToString();
                cliste.Add(c);
            }
            dr.Close();
            Baglanti.conn.Close();
            return(cliste);
        }
        public static ECategories GetIdOnly(int categoryID)
        {
            SqlCommand cmd = new SqlCommand("spCategories_GetIdOnly", Baglanti.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@CategoryID", categoryID);
            Baglanti.conn.Open();
            SqlDataReader dr       = cmd.ExecuteReader();
            ECategories   category = new ECategories();

            while (dr.Read())
            {
                category.ID          = Convert.ToInt32(dr["ID"]);
                category.Name        = dr["Name"].ToString();
                category.Description = dr["Description"].ToString();
            }
            dr.Close();
            Baglanti.conn.Close();
            return(category);
        }
Beispiel #17
0
        /// <summary>
        /// update a category created
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool Update(ECategories e)
        {
            bool res = false;

            try
            {
                using (var db = new DataAccess.Models.NewsDBContext())
                {
                    var query = (from x in db.Categories where x.IdCategory == e.IdCategory select x).FirstOrDefault();
                    query.Name        = e.Name;
                    query.Description = e.Description;
                    db.Categories.Update(query);
                    db.SaveChanges();
                    res = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(res);
        }
Beispiel #18
0
        protected void btnKaydet_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtTurAdi.Text))
            {
                List <ECategories> categoryList = BLLCategories.GetAll();

                categoryList = (from l in categoryList
                                where l.Name.Trim().ToLower().Equals(txtTurAdi.Text.Trim().ToLower())
                                select l).ToList();

                if (categoryList.Count == 0)
                {
                    ECategories kategori = new ECategories();
                    kategori.Name        = txtTurAdi.Text;
                    kategori.Description = TxtTurAciklamasi.Text;

                    if (BLLCategories.InsertNewCategory(kategori))
                    {
                        Response.Write("<script>alert('Tür kayıt işleminiz başarıyla gerçekleşmiştir.')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('Hata Oluştu!')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Kaydetmek istediğiniz tür zaten kayıtlı!')</script>");
                }
                txtTurAdi.Text        = String.Empty;
                TxtTurAciklamasi.Text = String.Empty;
                txtTurAdi.Focus();
            }
            else
            {
                Response.Write("<script>alert('Tür adı boş geçilemez!')</script>");
            }
        }
Beispiel #19
0
        /// <summary>
        /// Retornar una categoria por su ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ECategories Get(int id)
        {
            ECategories res = new ECategories();

            try
            {
                using (var db = new DataAccess.Models.NewsDBContext())
                {
                    var q = (from x in db.Categories where x.IdCategory == id select x).FirstOrDefault();
                    if (q != null)
                    {
                        res.IdCategory  = q.IdCategory;
                        res.Name        = q.Name;
                        res.Description = q.Description;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(res);
        }
Beispiel #20
0
        private void btnSil_Click(object sender, EventArgs e)
        {
            if (lstTurler.SelectedItems.Count > 0)
            {
                int          silinecekKategoriID = (int)lstTurler.SelectedValue;
                DialogResult result = MessageBox.Show("Silmek istediğinize emin misiniz ?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    ECategories category = new ECategories();

                    category.ID = silinecekKategoriID;
                    if (BLLCategories.Delete(category))
                    {
                        MessageBox.Show("Silme işleminiz başarıyla tamamlanmıştır.");
                        lstTurler.DataSource = BLLCategories.GetAll();
                    }
                }
            }
            else
            {
                MessageBox.Show("Lütfen silmek istediğiniz türü seçiniz!");
            }
        }
        public List <ECategories> GetAll()
        {
            List <ECategories> res = new List <ECategories>();

            try
            {
                var query = (from x in db.Categories select x).ToList();
                if (query.Any())
                {
                    foreach (var i in query)
                    {
                        ECategories e = new ECategories();
                        e.Name        = i.Name;
                        e.Description = i.Description;
                        res.Add(e);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(res);
        }
Beispiel #22
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtTurAdi.Text))
            {
                List <ECategories> categoryList = BLLCategories.GetAll();

                categoryList = (from l in categoryList
                                where l.Name.Trim().ToLower().Equals(txtTurAdi.Text.Trim().ToLower())
                                select l).ToList();

                if (categoryList.Count == 0)
                {
                    ECategories kategori = new ECategories();
                    kategori.Name        = txtTurAdi.Text;
                    kategori.Description = TxtTurAciklamasi.Text;

                    if (BLLCategories.InsertNewCategory(kategori))
                    {
                        MessageBox.Show("Kategori kayıt işlemi başarıyla gerçekleşmiştir!");
                        lstTurler.DataSource = BLLCategories.GetAll();
                        txtTurAdi.Clear();
                        TxtTurAciklamasi.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Kaydetmek istediğiniz tür zaten kayıtlıdır!");
                    txtTurAdi.Clear();
                    TxtTurAciklamasi.Clear();
                }
            }
            else
            {
                MessageBox.Show("Tür adı boş geçilemez!");
            }
        }
Beispiel #23
0
 protected void btnGuncelle_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtTurAdi.Text))
     {
         ECategories guncellenecek = new ECategories();
         guncellenecek.ID          = int.Parse(Request.QueryString["categoryID"]);
         guncellenecek.Name        = txtTurAdi.Text;
         guncellenecek.Description = TxtTurAciklamasi.Text;
         bool sonuc = BLLCategories.Update(guncellenecek);
         if (sonuc)
         {
             Response.Write("<script>alert('Harika! Güncellendi!');</script>");
             Response.Redirect("Kategoriler.aspx?scs=1");
         }
         else
         {
             Response.Write("<script>alert('Hay Aksi! Hata Oluştu!')</script>");
         }
     }
     else
     {
         Response.Write("<script>alert('Tür adı boş geçilemez!')</script>");
     }
 }
Beispiel #24
0
 public static bool Update(ECategories category)
 {
     DALCategories.Update(category);
     return(true);
 }
Beispiel #25
0
 public static bool Delete(ECategories category)
 {
     DALCategories.Delete(category);
     return(true);
 }
Beispiel #26
0
        protected override void Seed(DatabaseContext context)
        {
            EUser admin = new EUser()
            {
                Name                 = "Sinan",
                Surname              = "Tok",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                Gender               = "Erkek",
                Birthday             = DateTime.Now.AddYears(-22),
                Username             = "******",
                Password             = "******",
                ProfileImageFileName = "user.jpg",
                CreatedDate          = DateTime.Now,
                ModifiedDate         = DateTime.Now.AddMinutes(5),
                ModifiedUser         = "******"
            };

            EUser standartUser = new EUser()
            {
                Name                 = "Ada",
                Surname              = "Adale",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = false,
                Gender               = "Kadın",
                Birthday             = DateTime.Now.AddYears(-22),
                Username             = "******",
                Password             = "******",
                ProfileImageFileName = "user.jpg",
                CreatedDate          = DateTime.Now,
                ModifiedDate         = DateTime.Now.AddMinutes(5),
                ModifiedUser         = "******"
            };

            context.EUsers.Add(admin);
            context.EUsers.Add(standartUser);

            context.SaveChanges();

            ECategories eCategories1 = new ECategories()
            {
                Title        = "Cüzdan",
                Description  = "El Yapımı Cüzdan",
                CreatedDate  = DateTime.Now,
                ModifiedDate = DateTime.Now,
                ModifiedUser = "******"
            };

            ECategories eCategories2 = new ECategories()
            {
                Title        = "Kartlık",
                Description  = "El Yapımı kartlık",
                CreatedDate  = DateTime.Now,
                ModifiedDate = DateTime.Now,
                ModifiedUser = "******"
            };

            context.ECategories.Add(eCategories1); context.ECategories.Add(eCategories2);
            context.SaveChanges();

            EProducts eProducts1 = new EProducts()
            {
                Name          = "Legos Cüzdan",
                Description   = "Minimal tasarımı ile el yapımı cüzdan",
                Price         = 1200,
                Stock         = 500,
                IsApproved    = true,
                Category      = eCategories1,
                CreatedDate   = DateTime.Now,
                ModifiedDate  = DateTime.Now,
                IsFront       = true,
                ModifiedUser  = "******",
                ImageFileName = "legos.jpeg"
            };

            EProducts eProducts2 = new EProducts()
            {
                Name          = "Legos Kartlık",
                Description   = "Minimal tasarımı ile el yapımı cüzdan",
                Price         = 1200,
                Stock         = 500,
                IsApproved    = true,
                Category      = eCategories1,
                CreatedDate   = DateTime.Now,
                ModifiedDate  = DateTime.Now,
                IsFront       = true,
                ModifiedUser  = "******",
                ImageFileName = "legos.jpeg"
            };

            context.EProducts.Add(eProducts1); context.EProducts.Add(eProducts2);
            context.SaveChanges();

            EOrders eOrders = new EOrders()
            {
                Description = "First Order",
                IsApproved  = true,
                OrderDate   = DateTime.Now,
                TotalMoney  = 2400,
                UserId      = "1",
            };

            EOrdersDetail eOrdersDetail = new EOrdersDetail()
            {
                Order    = eOrders,
                Products = eProducts1
            };

            EOrdersDetail eOrdersDetail2 = new EOrdersDetail()
            {
                Order    = eOrders,
                Products = eProducts2
            };

            context.EOrders.Add(eOrders);
            context.SaveChanges();
            context.EOrdersDetail.Add(eOrdersDetail);
            context.EOrdersDetail.Add(eOrdersDetail2);
            context.SaveChanges();
        }