public async Task <IActionResult> Edit(int id, [Bind("brandName,brandId,glassType")] brands brands)
        {
            if (id != brands.brandId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(brands);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!brandsExists(brands.brandId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["brandId"] = new SelectList(_context.brands, "brandId", "brandId", brands.brandId);
            return(View(brands));
        }
Esempio n. 2
0
 public async Task <ReturnData <int> > AddBrands(string brnd, string createdby)
 {
     return(await Task.Run(() =>
     {
         try
         {
             brands brand = new brands
             {
                 name = brnd,
                 createdby = createdby
             };
             string url = ApiUrl.apiUrl() + "products/addbrand";
             string json = JsonConvert.SerializeObject(brand);
             using (var client = new WebClient())
             {
                 client.Headers.Add("content-type", "application/json");
                 var response = Encoding.ASCII.GetString(client.UploadData(url, "POST", Encoding.UTF8.GetBytes(json)));
                 return JsonConvert.DeserializeObject <ReturnData <int> >(response);
             }
         }
         catch (WebException ex) when(ex.Response is HttpWebResponse response)
         {
             ReturnData <int> err = new ReturnData <int>
             {
                 code = 500,
                 message = ex.Message
             };
             return err;
         }
     }));
 }
Esempio n. 3
0
 public static void Insertbrands(brands brands)
 {
     SqlParameter[] SqlParameters = new SqlParameter[3];
     SqlParameters[0] = new SqlParameter("@title", brands.title);
     SqlParameters[1] = new SqlParameter("@year", brands.year);
     SqlParameters[2] = new SqlParameter("@description", brands.description);
     SqlHelper.ExecuteDataset(MyProps.TestConnectionString, CommandType.StoredProcedure, DBProcedures.createBand, SqlParameters);
 }
Esempio n. 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            brands brands = db.brands.Find(id);

            db.brands.Remove(brands);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "brand_id,brand_name")] brands brands)
 {
     if (ModelState.IsValid)
     {
         db.Entry(brands).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(brands));
 }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "brand_id,brand_name")] brands brands)
        {
            if (ModelState.IsValid)
            {
                db.brands.Add(brands);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(brands));
        }
        public async Task <IActionResult> Create([Bind("brandName,brandId,glassType")] brands brands)
        {
            if (ModelState.IsValid)
            {
                _context.Add(brands);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["brandId"] = new SelectList(_context.brands, "brandId", "brandId", brands.brandId);
            return(View(brands));
        }
Esempio n. 8
0
        // GET: brands/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            brands brands = db.brands.Find(id);

            if (brands == null)
            {
                return(HttpNotFound());
            }
            return(View(brands));
        }
        public async Task <IActionResult> AddBrand([FromBody] brands brand)
        {
            ResponseAPI <int> rescode = new ResponseAPI <int>();

            try
            {
                var param = new DynamicParameters();
                param.Add("name", brand.name, DbType.String);
                param.Add("createdby", brand.createdby, DbType.String);
                param.Add("return", DbType.Int32, direction: ParameterDirection.Output);
                int response = await Task.FromResult(_dapper.GeneralCrud <int>("[dbo].[AddBrand]", param, commandType: CommandType.StoredProcedure));

                rescode.code    = response;
                rescode.message = ResponseMessage.StandardMessage(response);
                rescode.data    = response;
                return(Ok(JsonConvert.SerializeObject(rescode)));
            }
            catch (Exception ex)
            {
                rescode.code    = 500;
                rescode.message = ex.Message;
                return(StatusCode(500, JsonConvert.SerializeObject(rescode)));
            }
        }
Esempio n. 10
0
 public async Task <IActionResult> Insert([Microsoft.AspNetCore.Mvc.FromBody] brands brands)
 {
     brandsDataLayer.Insertbrands(brands);
     return(this.Ok());
 }