コード例 #1
0
        public IHttpActionResult Putbrand(int id, brand brand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != brand.brand_id)
            {
                return(BadRequest());
            }

            db.Entry(brand).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!brandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
 public BrandView(brand origianl)
 {
     this.id      = origianl.id;
     this.name    = origianl.name;
     this.image   = origianl.image;
     this.webSite = origianl.webSite;
 }
コード例 #3
0
        public int BADeleteBrand(brand objbranddetails)
        {
            DABrand objbrandDA  = new DABrand();
            int     returnValue = objbrandDA.DADeleteBrand(objbranddetails);

            return(returnValue);
        }
コード例 #4
0
        public ReturnValueRepo CreateBrand(int itemSubType, string brandName, string description)
        {
            var result = new
                         ReturnValueRepo();

            var newBrand = new brand
            {
                brand_parent_id   = itemSubType,
                brand_name        = brandName,
                brand_description = description
            };

            int commandResult = InventoryDatabase.Database.ExecuteSqlCommand(
                @"INSERT INTO [dbo].[brand]
                   ([brand_name]
                   ,[brand_parent_id]
                   ,[brand_description])
                VALUES
                   ({0}
                   ,{1}
                   ,{2})", brandName, itemSubType, description);

            //InventoryDatabase.brands.Add(newBrand);
            //if (InventoryDatabase.SaveChanges() > 0)
            if (commandResult > 0)
            {
                result.Success = true;
                result.Param1  = newBrand.brand_id.ToString();
            }
            return(result);
        }
コード例 #5
0
        public async Task <IActionResult> Edit(string id, [Bind("br_id,br_name")] brand brand)
        {
            if (id != brand.br_id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(brand);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!brandExists(brand.br_id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(brand));
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "id,name,activeFlag,createDate,updateDate")] brand brand, string editname, HttpPostedFileBase editlogo)
 {
     if (ModelState.IsValid)
     {
         brand modifybrand = db.brands.Find(brand.id);
         if (modifybrand != null)
         {
             if (editlogo != null && editlogo.ContentLength > 0)
             {
                 string fileName = System.IO.Path.GetFileName(editlogo.FileName);
                 string urlImage = Server.MapPath("~/Image/" + fileName);
                 editlogo.SaveAs(urlImage);
                 modifybrand.name       = editname;
                 modifybrand.updateDate = DateTime.Now;
                 modifybrand.logo       = "Image/" + fileName;
                 modifybrand.updateDate = DateTime.Now;
             }
             else
             {
                 modifybrand.name       = editname;
                 modifybrand.updateDate = DateTime.Now;
             }
         }
         db.Entry(modifybrand).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(brand));
 }
コード例 #7
0
        public IActionResult EditBrand(BrandViewModel model, string manufact, string type)
        {
            brand brand = new brand()
            {
                brand_key = model.Avto_Key
            };

            brand.expenses         = model.expenses;
            brand.name             = model.name;
            brand.body_type        = model.body_type;
            brand.type_of_avto     = _context.type_of_avto.Where(e => e.type_of_avto_key == Convert.ToInt32(type)).FirstOrDefault();
            brand.type_of_avto_key = _context.type_of_avto.Where(e => e.type_of_avto_key == Convert.ToInt32(type)).FirstOrDefault().type_of_avto_key;
            manufacturer manufacturer = _context.manufacturers.Where(e => e.name == manufact).FirstOrDefault();

            if (manufacturer == null)
            {
                manufacturer manufactur = new manufacturer()
                {
                    name = manufact
                };
                _context.manufacturers.Add(manufactur);
                _context.SaveChanges();
            }
            brand.manufacturer     = _context.manufacturers.Where(e => e.Manufacturer_Key == Convert.ToInt32(manufact)).FirstOrDefault();
            brand.manufacturer_key = _context.manufacturers.Where(e => e.Manufacturer_Key == Convert.ToInt32(manufact)).FirstOrDefault().Manufacturer_Key;

            _context.brands.Update(brand);
            _context.SaveChanges();
            return(RedirectToAction("ShowsBrand", "Shows"));
        }
コード例 #8
0
        // GET: brandsMain/Details/5
        public ActionResult Details(int id)
        {
            brand brandss = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:54964/api/brandsApi");
                //HTTP GET
                var responseTask = client.GetAsync("brandsApi?id=" + id.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <brand>();
                    readTask.Wait();

                    brandss = readTask.Result;
                }
                else //web api sent error response
                {
                    //log response status here..


                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }
            }
            return(View(brandss));
        }
コード例 #9
0
        public long Addbrand(brand brand)
        {
            try
            {
                brand insert_brand = new brand
                {
                    brand_name = brand.brand_name,
                    //created_by =
                    created_date = DateTime.Now,
                    //updated_by =
                    updated_date = DateTime.Now,
                    is_active    = true,
                    is_deleted   = false,
                };

                _entities.brands.Add(insert_brand);
                _entities.SaveChanges();
                long last_insert_id = insert_brand.brand_id;
                return(last_insert_id);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
コード例 #10
0
        public int BAAddbranddetails(brand objbranddetails)
        {
            DABrand objbrandDA  = new DABrand();
            int     returnValue = objbrandDA.DAAddbranddetails(objbranddetails);

            return(returnValue);
        }
コード例 #11
0
        public IActionResult AddBrand(BrandViewModel model, string type, string manufact)
        {
            brand brand = new brand()
            {
                expenses         = model.expenses,
                name             = model.name,
                body_type        = model.body_type,
                type_of_avto     = _context.type_of_avto.Where(e => e.name == type).FirstOrDefault(),
                type_of_avto_key = _context.type_of_avto.Where(e => e.name == type).FirstOrDefault().type_of_avto_key,
            };

            manufacturer manufacturer = _context.manufacturers.Where(e => e.name == manufact).FirstOrDefault();

            if (manufacturer == null)
            {
                manufacturer manufactur = new manufacturer()
                {
                    name = manufact
                };
                _context.manufacturers.Add(manufactur);
                _context.SaveChanges();
            }
            brand.manufacturer     = _context.manufacturers.Where(e => e.name == manufact).FirstOrDefault();
            brand.manufacturer_key = _context.manufacturers.Where(e => e.name == manufact).FirstOrDefault().Manufacturer_Key;

            _context.brands.Add(brand);
            _context.SaveChanges();
            return(RedirectToAction("AddBrand", "AddSome"));
        }
コード例 #12
0
        private void btnUpdateBrand_Click(object sender, EventArgs e)
        {
            if (gridBrand.SelectedCells[0].Value != null)
            {
                if (!tbBrands.Text.Equals(""))
                {
                    int id = Convert.ToInt32(gridBrand.SelectedCells[0].Value.ToString());

                    brand br = idc.brands.SingleOrDefault(x => x.brand_id == id);

                    br.brand_title = tbBrands.Text;

                    idc.SubmitChanges();
                    MessageBox.Show("Successfully updated a brand.");
                }
                else
                {
                    lblError.Text = "Enter a name to proceed.";
                }
            }
            else
            {
                lblError.Text = "Please select a row to update.";
            }
        }
コード例 #13
0
        public int DA_ValidateBrand(brand objBrandDetails)
        {
            int       val = 0;
            DataTable dt  = new DataTable();

            try
            {
                con.Open();
                MySqlCommand cmd = new MySqlCommand(objQuery.ValidateBrand, con);
                cmd.Parameters.AddWithValue("@BrandName", objBrandDetails.BrandName);
                //cmd.Parameters.AddWithValue("@CategoryName",objBrandDetails.ca)
                cmd.Parameters.AddWithValue("@CategoryId", objBrandDetails.CategoryId);
                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    val = 1;
                }
                else
                {
                    val = 0;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                //throw;
            }
            finally
            {
                con.Close();
            }
            return(val);
        }
コード例 #14
0
        public ActionResult Create([Bind(Include = "id,name,origin,describe,logo")] brand brand, FormCollection data, HttpPostedFileBase f)
        {
            if (ModelState.IsValid)
            {
                brand.name     = data["name"];
                brand.origin   = data["origin"];
                brand.describe = data["describe"];

                if (f != null)
                {
                    string fullname = Server.MapPath("~/img/brand/" + f.FileName);
                    f.SaveAs(fullname);
                    brand.logo = f.FileName;
                }
                else
                {
                    brand.logo = "";
                }

                db.brand.Add(brand);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(brand));
        }
コード例 #15
0
        public static List <brand> getBrands(string FilePath)
        {
            List <brand> brands = new List <brand>();

            // Объявляем и забиваем файл в документ
            XmlDocument xd = new XmlDocument();
            FileStream  fs = new FileStream(FilePath, FileMode.Open);

            xd.Load(fs);

            XmlNodeList list = xd.GetElementsByTagName("Row"); // Создаем и заполняем лист по тегу "user"

            for (int i = 0; i < list.Count; i++)
            {
                brand b = new brand();
                b.code1C = list[i].FirstChild.InnerText;
                b.name   = list[i].LastChild.InnerText;
                brands.Add(b);
            }

            // Закрываем поток
            fs.Close();

            return(brands);
        }
コード例 #16
0
        public void AddPrices_And_Delete_NULL_price()
        {
            var beer = new brand();
            beer.country = "TEST country";
            beer.description = "TEST descripion";
            beer.maker = "Refsvindinge";
            beer.name = "Ale nr 1673";
            beer.type = "TEST type";
            beer.volume = "TEST 22";
            beer.deleted = false;

            var result = _service.AddBeer( beer, 807 ); //remember to change values that match something existing in the DB

            var priceRecordId = _service.AddPrices(
                new establishment_brand { brand_id = result.id, establishment_id = 807, price = "22", size = "med", deleted = false },
                807,
                result.id ); //remember to change values that match something existing in the DB

            _service.AddPrices(
                new establishment_brand { brand_id = result.id, establishment_id = 807, price = "25", size = "med", deleted = false },
                807,
                result.id ); //remember to change values that match something existing in the DB

            Assert.IsNotNull( priceRecordId );

            var record = _service.Database.establishment_brands.Where( x => x.price == null && x.id == priceRecordId ).FirstOrDefault();
            Assert.IsNull( record );
        }
コード例 #17
0
ファイル: BeerService.cs プロジェクト: kryptonlove/Hublisher
        public brand AddBeer( brand beer, int establishmentId )
        {
            if (!Exists( beer.name )) {
                Database.brands.InsertOnSubmit( beer );
                Database.SubmitChanges();

                HublisherApp.UpdateGlobals();
            } else {
                var update = Database.brands.Where( b => b.id == beer.id && b.deleted == false ).FirstOrDefault();

                if (update != null) {
                    update.name = beer.name;
                    update.maker = beer.maker;
                    update.country = beer.country;
                    update.description = beer.description;
                    update.type = beer.type;
                    update.volume = beer.volume;
                    update.updated = DateTime.Now;

                    Database.SubmitChanges();
                    Database.Refresh( System.Data.Linq.RefreshMode.OverwriteCurrentValues, update );
                }
            }

            beer = HublisherApp._allBrands.Where( x => x.name.Equals( beer.name ) ).FirstOrDefault();

            if (!Exists( beer.id, establishmentId )) {
                this.Database.establishment_brands.InsertOnSubmit( new establishment_brand { brand_id = beer.id, establishment_id = establishmentId, deleted = false} );
                this.Database.SubmitChanges();
            }

            return beer;
        }
コード例 #18
0
 public ActionResult addBrand([Bind(Include = "id,name,activeFlag,createDate,updateDate,status")] brand brand, HttpPostedFileBase logoBrand)
 {
     if (logoBrand != null && logoBrand.ContentLength > 0)
     {
         string fileName = System.IO.Path.GetFileName(logoBrand.FileName);
         string urlImage = Server.MapPath("~/Image/" + fileName);
     }
 }
コード例 #19
0
        public ActionResult DeleteConfirmed(int id)
        {
            brand brand = db.brand.Find(id);

            db.brand.Remove(brand);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #20
0
 public static brandDTO toBrandDTO(this brand b1)
 {
     return(new brandDTO()
     {
         id = b1.id,
         name = b1.name
     });
 }
コード例 #21
0
        private void CreateItem()
        {
            DataAccess da   = new DataAccess();
            brand      item = new brand();

            item.name        = edtName.Text;
            item.description = edtDescr.Text;
            da.BrandCreate(item);
        }
コード例 #22
0
        /// <summary>
        /// 根据品牌简称获取全称
        /// </summary>
        /// <param name="brandName">品牌简称</param>
        /// <returns></returns>
        public string getBrandFullName(string brandName)
        {
            string s = string.Empty;
            pbxdatasourceDataContext context = new pbxdatasourceDataContext();
            brand MdBrand = new brand();

            s = (from c in context.brand where c.BrandAbridge == brandName select c).SingleOrDefault().BrandName;
            return(s);
        }
コード例 #23
0
        public void LoadItem(int id)
        {
            _id = id;
            DataAccess da = new DataAccess();
            brand      b  = da.GetBrand(id);

            edtName.Text  = b.name;
            edtDescr.Text = b.description;
        }
        // delete brand record
        public ActionResult Delete(int id)
        {
            brand b = mc.brands.Single(x => x.brand_id == id);

            if (b == null)
            {
                return(HttpNotFound());
            }
            return(View(b));
        }
コード例 #25
0
//farbe, räder, sitze, marke

        public car(farbe colour, brand marke, seat sitz, int sitzAnzahl)
        {
            mColour = colour;
            mMarke  = marke;
            for (int i = 0; i < sitzAnzahl; i++)
            {
                mSeatArray[i] = sitz;
            }
            mSitzAnzahl = sitzAnzahl;
        }
コード例 #26
0
        private void EditItem()
        {
            DataAccess da   = new DataAccess();
            brand      item = new brand();

            item.id          = _id;
            item.name        = edtName.Text;
            item.description = edtDescr.Text;
            da.BrandEdit(item);
        }
        // edit exsisting brand

        public ActionResult Edit(int id)
        {
            brand br = mc.brands.Single(s => s.brand_id == id);

            if (br == null)
            {
                return(HttpNotFound());
            }
            return(View(br));
        }
コード例 #28
0
 public ActionResult Edit([Bind(Include = "brand_id,brand_name")] brand brand)
 {
     if (ModelState.IsValid)
     {
         db.Entry(brand).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(brand));
 }
コード例 #29
0
        /// <summary>
        /// Thread body
        /// </summary>
        /// <param name="state"></param>
        private void StartWork(object state)
        {
            BrandView brandView  = state as BrandView;
            brand     savedBrand = null;
            brand     theBrand   = new brand();

            brandView.Merge(theBrand, editMode);

            AutoResetEvent nextOneAutoResetEvent           = new AutoResetEvent(false);
            EventHandler <save_BrandCompletedEventArgs> h1 = (s, e) =>
            {
                // TODO: handle error from server side
                savedBrand = e.Result;
                nextOneAutoResetEvent.Set();
            };

            Globals.WSClient.save_BrandCompleted += h1;
            Globals.WSClient.save_BrandAsync(theBrand);
            nextOneAutoResetEvent.WaitOne();
            Globals.WSClient.save_BrandCompleted -= h1;

            // Check return result. If failure, savedCategory will be null
            if (savedBrand != null)
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    brandView.Restore(new BrandView(savedBrand));
                });
            }
            else
            {
                // Show error message
                ShopproHelper.ShowMessageWindow(this, "Error", "Fail to save this entry.", false);

                // Back to readonly mode
                this.Dispatcher.BeginInvoke(delegate()
                {
                    // Restore cached UI data
                    brandView.CancelEdit();
                    this.brandDataForm.CancelEdit();
                });
            }

            // No unsaved item
            this.editMode = DataFormMode.ReadOnly;

            // Hide busy indicator
            ShopproHelper.HideBusyIndicator(this);

            // Go to original page if necessary
            if (this.ContentPageCtx.GotoAddNewPage)
            {
                ShopproHelper.GoToContentPage(this, PageEnum.BrandListPage);
            }
        }
コード例 #30
0
 private void LoadModel(brand brand)
 {
     try
     {
         Model.ItemsSource = context.model.Where(i => i.brand == brand.id).ToList();
     }
     catch (Exception ex)
     {
         MsgBox.Error(ex.Message);
     }
 }
        public ActionResult Delete(brand brObj)
        {
            if (ModelState.IsValid)
            {
                mc.Entry(brObj).State = EntityState.Deleted;

                mc.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View());
        }
コード例 #32
0
        public ActionResult Create([Bind(Include = "brand_id,brand_name")] brand brand)
        {
            if (ModelState.IsValid)
            {
                db.brands.Add(brand);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(brand));
        }
コード例 #33
0
        public void Update_Beer_Return_Updated()
        {
            var beer = new brand();
            beer.country = "TEST country";
            beer.description = "TEST descripion";
            beer.maker = "Refsvindinge";
            beer.name = "Ale nr 167111";
            beer.type = "TEST type";
            beer.volume = "TEST 22";
            beer.id = 11;
            beer.deleted = false;

            _service.AddBeer( beer, 807 );
            beer = _service.GetBeer( 11 );

            Assert.IsNotNull( beer.updated );
        }
コード例 #34
0
        public void Add_New_Beer_Return_New_Id()
        {
            var beer = new brand();
            beer.country = "TEST country";
            beer.description = "TEST descripion";
            beer.maker = "Refsvindinge";
            beer.name = "Ale nr 1673";
            beer.type = "TEST type";
            beer.volume = "TEST 22";
            beer.deleted = false;

            var result = _service.AddBeer( beer, 807 ); //remember to change values that match something existing in the DB

            var b = _service.Database.brands.OrderByDescending( e => e.id ).First();

            Assert.IsTrue( result.id == b.id );

            Console.WriteLine( b.id );
            Console.WriteLine( result.id );
        }