public async Task <IActionResult> Edit(int id, [Bind("ActivityCategoryId,ActivityDescription,CreationDate")] ActivityCategory activityCategory) { if (id != activityCategory.ActivityCategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(activityCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActivityCategoryExists(activityCategory.ActivityCategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(activityCategory)); }
public async Task <IActionResult> PutActivityCategory([FromRoute] int id, [FromBody] ActivityCategory @event) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != @event.ActivityCategoryId) { return(BadRequest()); } _context.Entry(@event).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//添加分类 protected void btnSubAdd_Click(object sender, EventArgs e) { string category = txtCategory.Text; if (category.Length == 0) { JSHelper.ShowAlert("输入不能为空!"); } else if (ActivityHelper.checkCategoryNameExit(category)) { JSHelper.ShowAlert("该分类已存在!"); } else { using (var db = new TeachingCenterEntities()) { var cate = new ActivityCategory(); cate.ActivityCategory_name = category; db.ActivityCategory.Add(cate); db.SaveChanges(); Server.Transfer("ActivityCatagoryManage.aspx"); //JSHelper.AlertThenRedirect("添加成功!", "ActivityCatagoryManage.aspx"); //Server.Transfer("ActivityCatagoryManage.aspx"); } } }
public async Task getActivitys(string key, ActivityCategory category) { try { switch (category) { case ActivityCategory.startAt: activityList = (await service.GET_Tlist <Activities>(key, category)).Where(x => x.Object.endDate >= DateTime.Now).ToList().convertObservable(); break; case ActivityCategory.endAt: activityList = (await service.GET_Tlist <Activities>(key, category)).Where(x => x.Object.endDate < DateTime.Now).ToList().convertObservable(); break; default: break; } check(); } catch (Exception ex) { Console.WriteLine("ActivityError Desc:" + ex.Message); isVisibleIndicator = false; } }
/// <summary> /// 修改 /// </summary> /// <param name="entity"></param> /// <returns></returns> public JsonResult Update(ActivityCategory entity) { ModelState.Remove("CreatedTime"); ModelState.Remove("UpdatedTime"); ModelState.Remove("IsDelete"); if (ModelState.IsValid) { var model = IActivityCategoryService.Find(entity.ID); if (model == null || (model != null && model.IsDelete)) { return(DataErorrJResult()); } if (IActivityCategoryService.IsExits(x => x.Name == entity.Name && x.ID != entity.ID)) { return(JResult(Core.Code.ErrorCode.system_name_already_exist, "")); } model.Name = entity.Name; model.Sort = entity.Sort; var result = IActivityCategoryService.Update(model); return(JResult(result)); } else { return(ParamsErrorJResult(ModelState)); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ActivityCategory cat = value as ActivityCategory; Color color = Colors.LightGray; string param = parameter != null?parameter.ToString() : String.Empty; if (cat == null) { if (param.Equals("Background")) { return(new SolidColorBrush(Colors.Transparent)); } else { return(new SolidColorBrush(color)); } } else { if (param.Equals("Background")) { return(new SolidColorBrush(ChangeColorBrightness(cat.Color, 0.8F))); } else { return(new SolidColorBrush(cat.Color)); } } }
internal static string GetActivitySql(ActivityCategory category) { var sql = @"select a.Id,a.Content,a.CreateTime,a.ViewCount,a.CommentCount,b.Account,b.Name,c.Avatar from T_Activitys a left join K_Users b on b.Id=a.UserId left join T_SnsUsers c on c.UserId=a.UserId where a.IsDelete=0"; switch (category) { case ActivityCategory.All: sql += " and (a.UserId=@UserId"; sql += " or exists(select 1 from T_UserFriends where FriendId=a.UserId and UserId=@UserId and Status=1)"; sql += " or exists(select 1 from T_UserAttentions where AttentionId=a.UserId and UserId=@UserId)"; sql += ")"; break; case ActivityCategory.Friend: sql += " and exists(select 1 from T_UserFriends where FriendId=a.UserId and UserId=@UserId and Status=1)"; break; case ActivityCategory.Attention: sql += " and exists(select 1 from T_UserAttentions where AttentionId=a.UserId and UserId=@UserId)"; break; } return(sql); }
/// <summary> /// Return a screen name for the activity category /// </summary> /// <param name="category"></param> /// <returns></returns> private string GetDescriptionForContextCategory(ActivityCategory category) { switch (category) { case ActivityCategory.DevCode: return("Development"); case ActivityCategory.DevDebug: return("Debugger Use"); case ActivityCategory.DevVc: return("Version Control"); case ActivityCategory.DevReview: return("Code Reviewing"); case ActivityCategory.ReadWriteDocument: return("Reading/Editing Documents"); case ActivityCategory.InformalMeeting: case ActivityCategory.InstantMessaging: return("Instant Messaging"); // Ad-Hoc Meeting case ActivityCategory.PlannedMeeting: return("Scheduled meetings"); case ActivityCategory.Planning: return("Planning"); case ActivityCategory.Email: return("Emails"); //case ActivityCategory.WebBrowsing: // return "Browsing (uncategorized)"; case ActivityCategory.WorkRelatedBrowsing: return("Browsing work-related"); // "Work related browsing"; case ActivityCategory.WorkUnrelatedBrowsing: return("Browsing work-unrelated"); // "Work un-related browsing"; case ActivityCategory.FileNavigationInExplorer: return("Navigation in File Explorer"); case ActivityCategory.Other: return("Other"); //case ActivityCategory.OtherMusic: // return "OtherMusic"; case ActivityCategory.Unknown: return("Uncategorized"); case ActivityCategory.OtherRdp: return("RDP (uncategorized)"); case ActivityCategory.Idle: return("Idle (e.g. break, lunch, meeting)"); } return("??"); // default color }
/// <summary> /// Return a random color for each context category (temporary implementation) /// </summary> /// <param name="category"></param> /// <param name="num"></param> /// <returns></returns> private static string GetHtmlColorForContextCategory(int num, ActivityCategory category) { const string noneColor = "#DDDDDD"; if (category == ActivityCategory.Idle) { return("'white'"); } switch (num) { case 1: return("'#A547D1'"); //"#6B238E";//"#00b300"; //"#007acb"; // darker blue case 2: return("'#C91BC7'"); //"#8EC4E8"; // fairest blue case 3: return("'#D7ADEB'"); //"#1484CE"; //fairest blue case 4: return("'#F9D1F8'"); // "#1484CE"; //fairest blue case 5: case 6: return("'#99EBFF'"); //#87CEEB";// "#3258E6";// "#00b300"; // dark green case 7: case 8: return("'#12A5F4'"); // "#C91BC7";//"#00cc00"; // fair green case 9: return("'#9DB7E8'"); // "#F9D1F8";//"#e855e8"; // dark violett case 10: return("'#326CCC'"); // "#2858a5";//"#ED77EB"; // fair violett //case ActivityCategory.WebBrowsing: case 11: return("'#FF9333'"); //orange "#FFE3CB";//"#FFA500"; case 12: return("'#FFC999'"); // "red"; // fair orange case 13: return("#'d3d3d3'"); // light gray case 14: case 15: case 16: return("gray"); case 17: return("white"); case 18: return(noneColor); } return(noneColor); // default color }
/// <summary> /// Return a color for each context category /// </summary> /// <param name="category"></param> /// <returns></returns> private string GetHtmlColorForContextCategory(ActivityCategory category) { var noneColor = "#DDDDDD"; switch (category) { case ActivityCategory.DevCode: return("#A547D1"); //"#6B238E";//"#00b300"; //"#007acb"; // darker blue case ActivityCategory.DevDebug: return("#C91BC7"); //"#8EC4E8"; // fairest blue case ActivityCategory.DevReview: return("#D7ADEB"); //"#1484CE"; //fairest blue case ActivityCategory.DevVc: return("#F9D1F8"); // "#1484CE"; //fairest blue !!! case ActivityCategory.ReadWriteDocument: //case ActivityCategory.ManualEditor: //return "#00cc00";//"#36c1c4"; // another blue case ActivityCategory.PlannedMeeting: return("#99EBFF"); //#87CEEB";// "#3258E6";// "#00b300"; // dark green case ActivityCategory.InformalMeeting: case ActivityCategory.InstantMessaging: return("#12A5F4"); // "#C91BC7";//"#00cc00"; // fair green case ActivityCategory.Planning: return("#9DB7E8"); // "#F9D1F8";//"#e855e8"; // dark violett case ActivityCategory.Email: return("#326CCC"); // "#2858a5";//"#ED77EB"; // fair violett //case ActivityCategory.WebBrowsing: case ActivityCategory.WorkRelatedBrowsing: return("#FF9333"); //orange "#FFE3CB";//"#FFA500"; case ActivityCategory.WorkUnrelatedBrowsing: return("#FFC999"); // "red"; // fair orange case ActivityCategory.FileNavigationInExplorer: return("#d3d3d3"); // light gray case ActivityCategory.Other: case ActivityCategory.OtherRdp: //case ActivityCategory.OtherMusic: case ActivityCategory.Unknown: return("gray"); case ActivityCategory.Idle: return("white"); case ActivityCategory.Uncategorized: return(noneColor); } return(noneColor); // default color }
public ActionResult DeleteConfirmed(int id) { ActivityCategory activityCategory = db.ActivityCategories.Find(id); db.ActivityCategories.Remove(activityCategory); db.SaveChanges(); return(RedirectToAction("Index")); }
static public string getCategoryName(int id) { using (var db = new TeachingCenterEntities()) { ActivityCategory ac = db.ActivityCategory.Single(a => a.ActivityCategory_id == id); return(ac.ActivityCategory_name); } }
static public int getCategoryId(string name) { using (var db = new TeachingCenterEntities()) { ActivityCategory ac = db.ActivityCategory.Single(a => a.ActivityCategory_name == name); return(ac.ActivityCategory_id); } }
public async Task <List <ActivityTemplateDTO> > GetActivityTemplates(ActivityCategory category, bool getLatestsVersionsOnly = false) { var allTemplates = await GetActivityTemplates(getLatestsVersionsOnly); var templates = allTemplates.Where(x => x.Category == category); return(templates.ToList()); }
public async Task <ActionResult> DeleteConfirmed(int id) { ActivityCategory activityCategory = await db.ActivityCategories.FindAsync(id); db.ActivityCategories.Remove(activityCategory); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
private static bool IsCategory(ActivityCategory category, string processName, string windowName) { var listToCheck = GetListForCategory(category); if (listToCheck == null) { return(false); } return(listToCheck.Any(processName.Contains) || listToCheck.Any(windowName.Contains)); }
public ActionResult Edit([Bind(Include = "ActivityCategoryId,ActivityDescription,CreationDate")] ActivityCategory activityCategory) { if (ModelState.IsValid) { db.Entry(activityCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(activityCategory)); }
public ActionResult Create([Bind(Include = "Id,Name")] ActivityCategory activityCategory) { if (ModelState.IsValid) { db.ActivityCategories.Add(activityCategory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(activityCategory)); }
public async Task <ActionResult> Edit([Bind("ActivityCategoryId,ActivityDescription,CreationDate")] ActivityCategory activityCategory) { if (ModelState.IsValid) { db.Entry(activityCategory).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(activityCategory)); }
public async Task <IActionResult> Create([Bind("ActivityCategoryId,ActivityDescription,CreationDate")] ActivityCategory activityCategory) { if (ModelState.IsValid) { _context.Add(activityCategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(activityCategory)); }
public async Task <IActionResult> PostActivityCategory([FromBody] ActivityCategory @event) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ActivityCategories.Add(@event); await _context.SaveChangesAsync(); return(CreatedAtAction("GetActivityCategory", new { id = @event.ActivityCategoryId }, @event)); }
public List <Activity> GetNewestActivities(string userId, ActivityCategory category, int pageIndex) { var sql = Helper.GetActivitySql(category); var sqlPage = Utils.GetPagingSql(sql, new string[] { "CreateTime desc" }, Setting.ActivitySize, pageIndex); return(connection.Query <Activity, SnsUser, Activity>( sqlPage , (activity, user) => { activity.User = user; return activity; } , new { UserId = userId } , null, false, "CommentCount", null, null ).ToList()); }
public ActionResult Create([Bind(Include = "ActivityCategoryId,ActivityDescription,CreationDate")] ActivityCategory activityCategory) { if (ModelState.IsValid) { activityCategory.CreationDate = DateTime.Now; db.ActivityCategories.Add(activityCategory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(activityCategory)); }
public async Task <ActionResult> Create([Bind("ActivityCategoryId,ActivityDescription,CreationDate")] ActivityCategory activityCategory) { activityCategory.CreationDate = DateTime.Now; if (ModelState.IsValid) { db.ActivityCategories.Add(activityCategory); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(activityCategory)); }
// GET: ActivityCategories/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } ActivityCategory activityCategory = await db.ActivityCategories.FindAsync(id); if (activityCategory == null) { return(NotFound()); } return(View(activityCategory)); }
// GET: ActivityCategories/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ActivityCategory activityCategory = db.ActivityCategories.Find(id); if (activityCategory == null) { return(HttpNotFound()); } return(View(activityCategory)); }
// GET: ActivityCategories/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ActivityCategory activityCategory = await db.ActivityCategories.FindAsync(id); if (activityCategory == null) { return(HttpNotFound()); } return(View(activityCategory)); }
public IActionResult ActivityCategoryHandler(ActivityCategory FromForm) { System.Console.WriteLine($"you have reached the backend of activity category {FromForm.Title}"); if (HttpContext.Session.GetInt32("UserId") == null) { return(RedirectToAction("index")); } int GetUserbyId = (int)HttpContext.Session.GetInt32("UserId"); FromForm.UserId = GetUserbyId; _context.Add(FromForm); _context.SaveChanges(); return(Json(new { Status = "Success" })); }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (values[0] == null || values[1] == null) { return(false); } if (values[0] is ActivityCategory == false) { return(false); } ActivityCategory category = (ActivityCategory)values[0]; string categoryName = (string)values[1]; return(category.CategoryName == categoryName); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { using (var db = new TeachingCenterEntities()) { int count = 0; for (int i = 0; i < this.rptCategory.Items.Count; i++) { CheckBox cbx = (CheckBox)rptCategory.Items[i].FindControl("chbCheck"); if (cbx != null) { if (cbx.Checked == true) { count++; } } } var list = from it in db.ActivityCategory select it; if (list.Count() == count) { JSHelper.ShowAlert("请至少留有一个分类!"); } else { for (int i = 0; i < rptCategory.Items.Count; i++) { CheckBox cbx = (CheckBox)rptCategory.Items[i].FindControl("chbCheck"); string name = ((Literal)rptCategory.Items[i].FindControl("ltName")).Text; if (cbx != null) { if (cbx.Checked == true) { ActivityCategory sc = db.ActivityCategory.Single(a => a.ActivityCategory_name == name); db.ActivityCategory.Remove(sc); db.SaveChanges(); } } } //JSHelper.AlertThenRedirect("删除成功!", "ActivityCatagoryManage.aspx"); Server.Transfer("ActivityCatagoryManage.aspx"); } } }
//Only Load ActivityCategory Data protected override void LoadData() { var activityCategoryRepository = new Repository<ActivityCategory>(); ActivityCategory = new ActivityCategory { Name = ValidValueName }; using (var ts = new TransactionScope()) { activityCategoryRepository.EnsurePersistent(ActivityCategory); ts.CommitTransaction(); } Assert.AreEqual(false, ActivityCategory.IsTransient()); }
private Builder(ActivityCategory category, string name) { _category = category; _name = name; }
public Group(ActivityCategory category, string name, IList<string> includeStrings, IList<string> excludeStrings) { Category = category; Name = name; _includeStrings = includeStrings; _excludeStrings = excludeStrings ?? new string[0]; }