public ActionResult Create(AuctionItemCreateViewModel v) { DateTime minDate = DateTime.Now; DateTime maxDate = minDate.AddDays(7); bool isEndDateValid = v.EndDateTime > minDate && v.EndDateTime < maxDate; if (ModelState.IsValid && isEndDateValid) { List <ItemImage> images = new List <ItemImage>(); for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase file = Request.Files[i]; if (file.ContentLength > 0 && file.ContentLength <= 4194304 && (file.ContentType == "image/gif" || file.ContentType == "image/jpeg" || file.ContentType == "image/png")) { images.Add(new ItemImage(BlobStorageHelper.UploadBlob(User.Identity.GetUserId(), Guid.NewGuid().ToString(), file))); } } var a = new AuctionItem(v, CategoryDB.GetCategoryByID(db, v.SelectedCategory), ApplicationUserDB.GetUserByID(db, User.Identity.GetUserId()), images); AuctionItemDB.Create(db, a); return(RedirectToAction("Index", "AuctionItem")); } if (!isEndDateValid) { ModelState.AddModelError("EndDateTime", $"Auction item end time must be between {minDate} and {maxDate}"); } return(View(v)); }
// GET: Category public ActionResult Index() { CategoryDB dbhandle = new CategoryDB(); ModelState.Clear(); return(View(dbhandle.GetCategory())); }
public JsonResult GetCategories() { try { using (var context = new ProjectManagementEntities()) { var obj = HttpContext.Session.GetString("SelectedProject"); var list = new List <Category>(); if (obj == null) { list = CategoryDB.GetInstance().GetAllCategory().ToList(); } else { var _projectId = JsonConvert.DeserializeObject <Project>(HttpContext.Session.GetString("SelectedProject")).Id; list = CategoryDB.GetInstance().GetAllCategoryByProjectId(_projectId).ToList(); } return(Json(list)); } } catch (System.Exception exc) { throw exc; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["user"] == null) { pnlBeforeLogin.Visible = true; } else { pnlAfterLogin.Visible = true; string[] fullName = MemberDB.getMemberbyEmail(Session["user"].ToString()).Name.Split(' '); lblUsername.Text = " " + fullName[0]; } ddlCategory.DataSource = CategoryDB.getAllCategory(); ddlCategory.DataBind(); ddlLocation.DataSource = LocationDB.getAllLocation(); ddlLocation.DataBind(); ddlLocation.Items.Insert(0, new ListItem("Singapore", "")); } }
public Form1() { InitializeComponent(); countryDB = new CountryDB(); comboBox1.DataSource = null; comboBox1.DataSource = countryDB.GetListCombobox(); comboBox1.DisplayMember = "NameCountry"; categoryDB = new CategoryDB(); comboBox3.DataSource = null; comboBox3.DataSource = categoryDB.GetListCombobox(); comboBox3.DisplayMember = "NameCategory"; discoveredDB = new DiscoveredDB(); comboBox5.DataSource = null; comboBox5.DataSource = discoveredDB.GetDiscoveredBox(); comboBox5.DisplayMember = "Status"; dB = new AdvertisementDB(); // создаем экземпл¤р пагинатора дл¤ отображени¤ 10 записей на странице. „исло 10 можно сделать переменной и вынести в настройки paginator = new Paginator <AdvertisementDB, Advertisement>(dB, 10); // дл¤ отображени¤ данных в листвью ¤ сделал отдельный класс // в нем кэшируютс¤ строки viewer = new ListViewViewer(listView1, 5, 10); // вызываем обновление всех данных и событий // за счет того, что данный метод вызываетс¤ ѕќ—Ћ≈ создани¤ пагинатора интерфейс успевает подписатьс¤ на событи¤ пагинатора и нормально отобразить все данные dB.Save(); }
protected void btnSubmit_Click(object sender, EventArgs e) { Item newItem = new Item(); newItem.CategoryName = CategoryDB.getCategorybyName("Services"); newItem.Deposit = Convert.ToDecimal(tbxRefundableDeposit.Text); newItem.Location = LocationDB.getLocationbyID(ddlMRTLocation.SelectedValue); newItem.PricePerDay = Convert.ToDecimal(tbxPricePerDay); newItem.PricePerWeek = Convert.ToDecimal(tbxPricePerWeek); newItem.PricePerMonth = Convert.ToDecimal(tbxPricePerMonth); newItem.Renter = MemberDB.getMemberbyEmail(Session["user"].ToString()); newItem.Description = tbxDescription.InnerText; newItem.PostedDate = DateTime.Now; newItem.ItemID = Utility.convertIdentitytoPK("ITM", ItemDB.addItem(newItem)); List <string> tags = Utility.findHashTags(tbxDescription.InnerText); if (tags.Count > 0) { foreach (string t in tags) { if (!TagDB.isTagPresent(t)) { TagDB.addTag(t); } ItemTagDB.addItemTag(newItem, t); } } }
public void NewDB() { var l = CategoryDB.LoadCategories(); Assert.IsNotNull(l); Assert.AreEqual(0, l.Count); }
public void FindNotThere() { var m = new myMeetingListRef(); var r = CategoryDB.Find(m); Assert.IsNull(r); }
public void UpdateCategory(long categoryId, CategoryDB category) { var category1 = _context.Categories.Find(categoryId); category1.Name = category.Name; _context.SaveChanges(); }
public MyPageModel(IConfiguration configuration) { _configuration = configuration; productDB = new ProductDB(); categoryDB = new CategoryDB(); connectionString = _configuration.GetConnectionString("myCompanyDB"); }
public void KnownTitleUpdated() { var unknown1 = new CategoryConfigInfo() { CategoryTitle = "Dude", DisplayOnHomePage = true, MeetingList = new myMeetingListRef() }; var list = new List <CategoryConfigInfo>() { unknown1 }; CategoryDB.SaveCategories(list); var unknown = new CategoryConfigInfo() { CategoryTitle = "hi", DisplayOnHomePage = false, MeetingList = new myMeetingListRef() }; var ccvm = new CategoryConfigViewModel(unknown.MeetingList); ccvm.CategoryTitle = "There"; var info = FindDBConfigInfo(unknown.MeetingList); Assert.IsNotNull(info); Assert.AreEqual("There", info.CategoryTitle); }
public void KnownUnsubscribed() { var unknown1 = new CategoryConfigInfo() { CategoryTitle = "hi", DisplayOnHomePage = true, MeetingList = new myMeetingListRef() }; var list = new List <CategoryConfigInfo>() { unknown1 }; CategoryDB.SaveCategories(list); var unknown = new CategoryConfigInfo() { CategoryTitle = "hi", DisplayOnHomePage = false, MeetingList = new myMeetingListRef() }; var ccvm = new CategoryConfigViewModel(unknown.MeetingList); ccvm.IsSubscribed = false; var info = FindDBConfigInfo(unknown.MeetingList); Assert.IsNull(info); }
/// <summary> /// Initialize the settings interface for a particular category. /// </summary> public CategoryConfigViewModel(IMeetingListRef meeting) { // First, we need to determine if this meeting is already in the // database. _meetingInfo = CategoryDB.Find(meeting); InitializeVM(meeting); }
public async Task <List <Category> > getAllCategoriesAsync() { List <Category> categories = new List <Category>(); categories = await CategoryDB.getAllCategories(); return(categories); }
public static List <Category> ListOfCategory(int page, int pageSize, string searchValue, out int rowCount) { if (page < 1) { page = 1; } rowCount = CategoryDB.Count(searchValue); return(CategoryDB.List(page, pageSize, searchValue)); }
public void ResetCategoryDB() { CategoryDB.ResetCategoryDB(); Locator.CurrentMutable.Register(() => new JsonSerializerSettings() { ObjectCreationHandling = ObjectCreationHandling.Replace, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, TypeNameHandling = TypeNameHandling.All, }, typeof(JsonSerializerSettings), null); }
public void EmptyDB() { var l = new List <CategoryConfigInfo>(); CategoryDB.SaveCategories(l); var r = CategoryDB.LoadCategories(); Assert.IsNotNull(r); Assert.AreEqual(0, r.Count); }
public List <CategoryDTO> GetListCategory() { List <CategoryDTO> LsDTO = CategoryConvert.FromDBToDTO(CategoryDB.GetParent()); foreach (CategoryDTO dto in LsDTO) { dto.ListChildCategory = GetChildCategory(int.Parse(dto.Id)); } return(LsDTO); }
// GET: Product/Edit/5 public ActionResult Edit(int id) { ProductDB pd = new ProductDB(); CategoryDB Cdb = new CategoryDB(); var li = Cdb.GetCategory(); ViewBag.list = li; return(View(pd.GetProducts().Find(smodel => smodel.id == id))); }
/// <summary> /// Danh sách category /// </summary> /// <param name="page">trang</param> /// <param name="pageSize">tổng số trang</param> /// <param name="searchValue">giá trị tìm kiếm</param> /// <returns></returns> public static List <Category> Categorys_List(int page, int pageSize, string searchValue) { if (page < 1) { page = 1; } if (pageSize <= 0) { pageSize = 30; } return(CategoryDB.List(page, pageSize, searchValue)); }
public static List <Category> ListOfCategorys(int page, int pagaSize, string searchValue) { if (page < 1) { page = 1; } if (pagaSize < 0) { pagaSize = 2000; } return(CategoryDB.List(page, pagaSize, searchValue)); }
public IHttpActionResult Get() { try { Category[] c = CategoryDB.GetAllCategories().ToArray(); return(Ok(c)); } catch (Exception ex) { return(Content(HttpStatusCode.BadRequest, ex)); } }
public JsonResult DeleteCategory(int _id) { try { var result = CategoryDB.GetInstance().DeleteCategory(_id); return(Json(result)); } catch (System.Exception exc) { throw exc; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlCategory.DataSource = CategoryDB.getAllCategory(); ddlCategory.DataBind(); ddlLocation.DataSource = LocationDB.getAllLocation(); ddlLocation.DataBind(); ddlLocation.Items.Insert(0, new ListItem("Singapore", "")); } }
public ActionResult Edit(int id, Category smodel) { try { CategoryDB sdb = new CategoryDB(); sdb.UpdateCategory(smodel); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Update(AuctionItemCreateViewModel v) { if (ModelState.IsValid) { var a = new AuctionItem(v, CategoryDB.GetCategoryByID(db, v.SelectedCategory), ApplicationUserDB.GetUserByID(db, User.Identity.GetUserId())); if (AuctionItemDB.Update(db, a)) { return(RedirectToAction("Index", "AuctionItem")); } ModelState.AddModelError("UpdateFailed", "Currently logged in user is not the owner of this item."); } return(View(v)); }
public async Task ResetCategoryDB() { CategoryDB.ResetCategoryDB(); Locator.CurrentMutable.Register(() => new JsonSerializerSettings() { ObjectCreationHandling = ObjectCreationHandling.Replace, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, TypeNameHandling = TypeNameHandling.All, }, typeof(JsonSerializerSettings), null); Locator.CurrentMutable.Register(() => new factoryGenerator(), typeof(IMeetingListRefFactory)); await Blobs.LocalStorage.Flush(); await Blobs.LocalStorage.InvalidateAll(); }
public void RemoveNonCategoryInfo() { var ci = new CategoryConfigInfo() { CategoryTitle = "hi", DisplayOnHomePage = false, MeetingList = new myMeetingListRef() }; CategoryDB.Remove(ci); var r = CategoryDB.LoadCategories(); Assert.IsNotNull(r); Assert.AreEqual(0, r.Count); }
public void FindThere() { var ci = new CategoryConfigInfo() { CategoryTitle = "hi", DisplayOnHomePage = false, MeetingList = new myMeetingListRef() }; CategoryDB.UpdateOrInsert(ci); var m = new myMeetingListRef(); var r = CategoryDB.Find(ci.MeetingList); Assert.IsNotNull(r); Assert.AreEqual("hi", r.CategoryTitle); }
public void Init() { barcode = new Barcode { Id = Guid.NewGuid().ToString(), Code = "456731556", ProductName = "Some product" }; barcodeDB = new BarcodeDB { Id = Guid.NewGuid().ToString(), Code = "456731556" }; selectedList = new List <ProductDB>(); mapConfig = new MapperConfiguration(cfg => { cfg.CreateMap <Product, ProductDB>() .ForMember(m => m.Created, opt => opt.MapFrom(p => p.Name != null ? DateTime.UtcNow : default(DateTime))) .ForMember(m => m.Modified, opt => opt.UseValue((DateTime?)null)) .ForMember(m => m.Barcode, opt => opt.Ignore()) .ReverseMap(); cfg.AddProfile <CategoryProfile>(); }); mapper = new Mapper(mapConfig); mockProductRepository = new Mock <IProductRepository>(); mockCategoryRepository = new Mock <ICategoryRepository>(); mockBarcodeService = new Mock <IBarcodeService>(); category = new Category { Id = new Guid().ToString(), Name = "Vegetables", Description = "Some description" }; product = new Product { Id = new Guid().ToString(), Name = "Some name" }; productDB = new ProductDB { Id = new Guid().ToString(), Name = "Some name" }; categoryDB = new CategoryDB { Id = new Guid().ToString(), Name = "Some name" }; }
public CategoryBs() { objDb = new CategoryDB(); }