public Chambre(int numero, types type, categories categories, int prix) { this.numero = numero; this.type = type; this.categories = categories; this.prix = prix; }
public async Task <IActionResult> Edit(string id, [Bind("id,catname")] categories categories) { if (id != categories.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categories); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!categoriesExists(categories.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(categories)); }
private void BtnSearch_Click(object sender, RoutedEventArgs e) { dataAccess data = new dataAccess(); categories cat = new categories(); DataTable table = new DataTable(); if (Search.Text == null || Search.Text == "") { MessageBox.Show("Category Number required"); } else { cat.CategoryID = int.Parse(Search.Text); table = data.getCategory(cat); if (table.Rows.Count < 0) { MessageBox.Show("Your Searched Category type does not exist !!"); } else { foreach (DataRow row in table.Rows) { CategoryNumber.Text = row["CategoryID"].ToString(); CategoryName.Text = row["CategoryName"].ToString(); CategoryDescription.Text = row["Description"].ToString(); } } } }
public async Task <ReturnData <int> > AddCategory(string category, string createdby) { return(await Task.Run(() => { try { categories brand = new categories { name = category, createdby = createdby }; string url = ApiUrl.apiUrl() + "products/AddCategory"; 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; } })); }
public void new_nav() { categories nav = new categories(); PropertyBag["nav"] = nav; RenderView("../admin/nav/_editor"); }
public categories GetRandomCat() { System.Array A = System.Enum.GetValues(typeof(categories)); categories category = (categories)A.GetValue(UnityEngine.Random.Range(0, A.Length)); return(category); }
public ActionResult Edit(int id) { BAL bAL = new BAL(); categories categories = bAL.CategoryList.Single(c => c.categoryID == id); return(View(categories)); }
public CategoryViewModel(categories category) { this.Id = category.Id; this.Name = category.name; this.Order = category.status; this.articleTypes = category.articleTypes; }
public Chambre() { this.numero = 0; this.type = types.Individuelle; this.categories = categories.Confort; this.prix = 0; }
public ActionResult Create(categories consulta, HttpPostedFileBase file) { consulta.created = DateTime.Now; consulta.updated = DateTime.Now; //consulta.status = Convert.ToInt32(Request.Form["status"]); //Preenche o campo Ordem da tabela de Categorias. var ultimoitem = new categories(); var consultaOrdem = (from ev in db.categories orderby ev.ordem ascending select ev).ToList(); if (consultaOrdem.Count() > 0) { ultimoitem = consultaOrdem[consultaOrdem.Count - 1]; consulta.ordem = ultimoitem.ordem + 1; } else { consulta.ordem = 1; } //Cadastra a Categoria. if (ModelState.IsValid) { //Save Post db.categories.Add(consulta); db.SaveChanges(); TempData["acao"] = "Dados inseridos com sucesso"; } return(RedirectToAction("Index")); }
public IActionResult CreateCategory(CategoryViewModel newCat) { int?id = HttpContext.Session.GetInt32("Id"); if (ModelState.IsValid) { categories checkingCat = _context.categories.Where(x => x.name == newCat.Name).FirstOrDefault(); if (checkingCat != null) { ModelState.AddModelError("name", "already in the database"); List <categories> category = _context.categories.OrderBy(x => x.name).ToList(); ViewBag.allCategories = category; return(View("category")); } else { categories newcat = new categories() { usersid = (int)id, name = newCat.Name, created_at = DateTime.Now, updated_at = DateTime.Now }; _context.Add(newcat); _context.SaveChanges(); return(RedirectToAction("Categories")); } } List <categories> allCategories = _context.categories.OrderBy(x => x.name).ToList(); ViewBag.allCategories = allCategories; return(View("category")); }
public ActionResult DeleteConfirmed(int id) { categories category = _categoryManager.Find(x => x.id == id); _categoryManager.Delete(category); return(RedirectToAction("Index")); }
public IHttpActionResult Putcategories(int id, categories categories) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != categories.Id) { return(BadRequest()); } db.Entry(categories).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!categoriesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void edit_nav(int id) { HelperService.writelog("Editing nav categories", id); categories nav = ActiveRecordBase <categories> .Find(id); PropertyBag["nav"] = nav; RenderView("../admin/nav/_editor"); }
//cap nhat category public void updateCategory(categories ctg) { con.Open(); SqlCommand cmd = new SqlCommand("update categories set cat_name=N'" + ctg.cat_name + "' where cat_id=" + ctg.cat_id + "", con); cmd.ExecuteNonQuery(); con.Close(); }
public ActionResult DeleteConfirmed(int id) { categories categories = db.categories.Find(id); db.categories.Remove(categories); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { categories ct = (categories)Session["ctg"]; txtcat_name.Text = ct.cat_name; DataBind(); } }
public IActionResult CategoryDetail(int id) { categories category = _context.categories.Where(x => x.id == id).Include(x => x.CatPro).ThenInclude(x => x.product).FirstOrDefault(); List <products> allProducts = _context.products.ToList(); ViewBag.category = category; ViewBag.allProducts = allProducts; return(View("categorydetail")); }
public void SearchModeKeywordBasicVisibilityTest() { var categories = new categories(); var searchViewModel = Mediator.Index(null, ApprenticeshipSearchMode.Keyword, false).ViewModel; var view = categories.RenderAsHtml(searchViewModel); view.GetElementbyId("categories").Attributes["class"].Value.Contains(" active").Should().BeFalse(); }
// Tạo thêm category public void addCategory(categories ctg) { con.Open(); SqlCommand cmd = new SqlCommand("insert into categories values(@cat_name)", con); cmd.Parameters.AddWithValue("cat_name", ctg.cat_name); cmd.ExecuteNonQuery(); con.Close(); }
public ActionResult Edit([Bind(Include = "categoryId,categoryName")] categories categories) { if (ModelState.IsValid) { db.Entry(categories).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(categories)); }
public ActionResult Create([Bind(Exclude = "categoryID")] categories categories) { if (ModelState.IsValid) { BAL bAL = new BAL(); bAL.AddCategories(categories); return(RedirectToAction("Index")); } return(View(categories)); }
protected void updateCategories_Command(object sender, CommandEventArgs e) { if (e.CommandName == "updatecategories") { int u = Convert.ToInt16(e.CommandArgument); categories ct = ctg.get1Category(u); Session["ctg"] = ct; Response.Redirect("updateCategory.aspx"); } }
public void SearchModeCategoryBasicVisibilityTest() { var categories = new categories(); var searchViewModel = Mediator.Index(ApprenticeshipSearchMode.Category).ViewModel; var view = categories.RenderAsHtml(searchViewModel); view.GetElementbyId("categories").Attributes["class"].Value.Contains(" active").Should().BeTrue(); view.GetElementbyId("category-load-failed").Should().BeNull(); }
public ActionResult Create([Bind(Include = "categoryId,categoryName")] categories categories) { if (ModelState.IsValid) { db.categories.Add(categories); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(categories)); }
public void setCategories(string a) { if (a == "Confort") { this.categories = categories.Confort; } if (a == "Luxe") { this.categories = categories.Luxe; } }
public void SearchModeCategoryNullCategoriesVisibilityTest() { ReferenceDataService.Setup(rds => rds.GetCategories()); var categories = new categories(); var searchViewModel = Mediator.Index(null, ApprenticeshipSearchMode.Category, false).ViewModel; var view = categories.RenderAsHtml(searchViewModel); view.GetElementbyId("category-load-failed").Should().NotBeNull(); }
public void CategorySelected() { var categories = new categories(); var searchViewModel = Mediator.Index(null, ApprenticeshipSearchMode.Category, false).ViewModel; searchViewModel.Category = "3"; var view = categories.RenderAsHtml(searchViewModel); view.GetElementbyId("category-" + searchViewModel.Category.ToLower()).Should().NotBeNull(); }
public IHttpActionResult GetCategory(int id) { categories categories = db.categories.Find(id); if (categories == null) { return(NotFound()); } return(Ok(categories)); }
public ActionResult Create(categories category) { if (ModelState.IsValid) { category.id = null; _categoryManager.Insert(category); return(RedirectToAction("Index")); } return(View(category)); }
//ADD public static bool AddCategory(categories c) { Context.categories.Add(c); try { Context.SaveChanges(); } catch (DbUpdateException dbEx) { return false; } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult item in ex.EntityValidationErrors) { // Get entry DbEntityEntry entry = item.Entry; string entityTypeName = entry.Entity.GetType().Name; // Display or log error messages foreach (DbValidationError subItem in item.ValidationErrors) { string message = string.Format("Error '{0}' occurred in {1} at {2}", subItem.ErrorMessage, entityTypeName, subItem.PropertyName); Console.WriteLine(message); } // Rollback changes switch (entry.State) { case EntityState.Added: entry.State = EntityState.Detached; break; case EntityState.Modified: entry.CurrentValues.SetValues(entry.OriginalValues); entry.State = EntityState.Unchanged; break; case EntityState.Deleted: entry.State = EntityState.Unchanged; break; } } return false; } Context.Entry(c).Reload(); return true; }
public static List<subcategories> GetAllSubCategoryByCategory(categories cat) { return GetAllSubCategories().Where(sc => sc.categories_Id == (cat.Id)).ToList(); }
protected void ddlexcellst_SelectedIndexChanged(object sender, EventArgs e) { try { if (ddlexcellst.SelectedIndex == 0) { Label2.Visible = true; } else { Label2.Visible = false; OAuth2Parameters parameters_lst = oauthcredentials(); GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "Fusion-SpreadSheet", parameters_lst); SpreadsheetsService service = new SpreadsheetsService("Fusion-SpreadSheet"); service.RequestFactory = requestFactory; service.RequestFactory = requestFactory; // TODO: Authorize the service object for a specific user (see other sections) // Instantiate a SpreadsheetQuery object to retrieve spreadsheets. SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed feed = service.Query(query); if (feed.Entries.Count == 0) { // TODO: There were no spreadsheets, act accordingly. } // TODO: Choose a spreadsheet more intelligently based on your // app's needs. SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[Convert.ToInt32(ddlexcellst.SelectedIndex) - 1]; //Response.Write(spreadsheet.Title.Text + "\n"); // Get the first worksheet of the first spreadsheet. // TODO: Choose a worksheet more intelligently based on your // app's needs. WorksheetFeed wsFeed = spreadsheet.Worksheets; WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0]; // Define the URL to request the list feed of the worksheet. AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null); // Fetch the list feed of the worksheet. ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString()); listQuery.StartIndex = 0; ListFeed listFeed = service.Query(listQuery); // Iterate through each row, printing its cell values. List<category> chart_categories = new List<category>(); ChartModels result = new ChartModels(); categories final_categories = new categories(); List<categories> list_categories = new List<categories>(); List<dataset> collect_dataset = new List<dataset>(); foreach (ListEntry row in listFeed.Entries) { // Print the first column's cell value TableRow tr = new TableRow(); // Response.Write(row.Title.Text + "\n"); // Iterate over the remaining columns, and print each cell value dataset final_dataset = new dataset(); List<data> collect_data = new List<data>(); foreach (ListEntry.Custom element in row.Elements) { if (row.Title.Text == "Row: 2") { category chart_category = new category(); chart_category.label = element.Value.ToString(); chart_categories.Add(chart_category); } else { data data_value = new data(); final_dataset.seriesname = row.Title.Text; int n; bool isNumeric = int.TryParse(element.Value, out n); if (isNumeric) { data_value.value = element.Value.ToString(); collect_data.Add(data_value); } } // Response.Write(element.Value + "\n"); TableCell tc = new TableCell(); if (row.Title.Text == "Row: 2") { tc.Text = ""; } else tc.Text = element.Value; tr.Cells.Add(tc); } Table1.Rows.Add(tr); if (collect_data.Count != 0) { final_dataset.data = collect_data; collect_dataset.Add(final_dataset); } } final_categories.category = chart_categories; result.dataset = collect_dataset; list_categories.Add(final_categories); result.categories = list_categories; JavaScriptSerializer js = new JavaScriptSerializer(); string res = js.Serialize(result); string chartjson = JsonConvert.SerializeObject(result.categories); StringBuilder strJson = new StringBuilder(); strJson.Append("{" + "'chart': {" + "'caption': 'Quarterly revenue'," + "'subCaption':'Last year'," + "'xAxisName':'Quarter (Click to drill down)'," + "'subcaptionFontColor':'#0075c2'," + "'numberPrefix': '$'," + "'formatNumberScale': '1'," + "'placeValuesInside': '1'," + "'decimals': '0'" + "},"); strJson.Append("'categories':"); strJson.Append(chartjson); strJson.Append(","); strJson.Append("'dataset':"); string chartdatajson = JsonConvert.SerializeObject(result.dataset); strJson.Append(chartdatajson); strJson.Append("}"); // Initialize the chart. Chart sales = new Chart("mscolumn3d", "myChart", "600", "350", "json", strJson.ToString()); // Render the chart. Label1.Text = sales.Render(); } } catch (Exception) { Response.Redirect("Default.aspx"); } }
//UPDATE public static int UpdateCategory(categories category) { categories categoryToUpdate = GetCategoryById(category.Id); categoryToUpdate.Name = category.Name; categoryToUpdate.associations = category.associations; categoryToUpdate.subcategories = category.subcategories; int affectedRows; try { affectedRows = Context.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult item in ex.EntityValidationErrors) { // Get entry DbEntityEntry entry = item.Entry; string entityTypeName = entry.Entity.GetType().Name; // Display or log error messages foreach (DbValidationError subItem in item.ValidationErrors) { string message = string.Format("Error '{0}' occurred in {1} at {2}", subItem.ErrorMessage, entityTypeName, subItem.PropertyName); Console.WriteLine(message); } // Rollback changes switch (entry.State) { case EntityState.Added: entry.State = EntityState.Detached; break; case EntityState.Modified: entry.CurrentValues.SetValues(entry.OriginalValues); entry.State = EntityState.Unchanged; break; case EntityState.Deleted: entry.State = EntityState.Unchanged; break; } } return affectedRows = 0; } Context.Entry(categoryToUpdate).Reload(); return affectedRows; }
public static List<events> FilterEvents(DateTime? sT, DateTime? eT, communities c, associations a, categories cat, subcategories subCat, string word) { List<events> resultList = GetAllEvents(); if (sT != null) { resultList = resultList.Where(e => e.StartDate >= sT).ToList(); } if (eT != null) { resultList = resultList.Where(e => e.EndDate <= eT).ToList(); } if (c != null) { var preResultList = new List<events>(); preResultList.AddRange(resultList.Where(e => e.communities.Contains(c)).ToList()); List<events> list = resultList; foreach (var ev in c.associations.SelectMany(asso => list.Where(e => e.associations.Contains(asso)).Where(ev => !preResultList.Contains(ev)))) { preResultList.Add(ev); } resultList = preResultList; } if (a != null) { resultList = resultList.Where(e => e.associations.Contains(a)).ToList(); } if (cat != null) { List<events> eventsInAsso = new List<events>(); foreach (var asso in cat.associations) { eventsInAsso.AddRange(resultList.Where(e => e.associations.Contains(asso))); } resultList = eventsInAsso; } if (subCat != null) { resultList = resultList.Where(e => e.subcategories.Contains(subCat)).ToList(); } if (!String.IsNullOrWhiteSpace(word)) { resultList = GetEventsFromListBySearchWord(resultList, word); } return resultList; }