public void Delete(DeleteCmd command) { Notification.Clear(); if (command.IsValid()) { IEnumerable <Category> results = _categoryRepository.Filter(new FilterCmd() { Category = command.Id }); if (Notification.IsValid()) { foreach (Category item in results) { _categoryRepository.Remove(item); } } if (_categoryRepository.Notification.HasNotifications) { Notification.AddNotifications(_categoryRepository.Notification.Notifications); } } else { Notification.AddNotifications(command.Validation); } }
public async Task Handle(DeleteCmd message, CancellationToken token) { var item = await _session.Get <Table>(message.Id, message.ExpectedVersion, token); item.Delete(); await _session.Commit(token); }
/// <summary> /// 创建删除命令对象 /// </summary> /// <returns></returns> protected StockCmd CreateDeleteCmd(IDvTable Table) { StockCmd isert = new DeleteCmd(); isert.CreateCmd(Table); return(isert); }
public LecturerPageVM(string dbcontextName, ISystemUser loggedInLectuer) : base(dbcontextName) { try { rowsToReturn = 20; IsConfirmed = false; SubgridContext = SubgridContext.Groups; //commands NewModeCmd = new NewModeCmd(this); SaveFormCmd = new SaveCmd(this); DeleteCmd = new DeleteCmd(this); CancelCmd = new CancelCmd(this); NewPassHashCmd = new NewPassHashCmd(this); ToggleAdminRoleCmd = new ToggleAdminRoleCmd(this); //TODO: will likely need to attach lecturer to the DbContext.. User = UnitOfWork.LecturerRepo.Get(loggedInLectuer.Id); SearchTxt = ""; SelectedLecturer = new Lecturer(); //TODO: figure out Async with EF and Pagination/ limit the results (limit probably best) List <Lecturer> results = UnitOfWork.LecturerRepo.GetTopXFromSearch(null, rowsToReturn).ToList(); Lecturers = new ObservableCollection <Lecturer>(results); Mediator.Register(MediatorChannels.PoolingUpdate.ToString(), PoolingUpdate); } catch (Exception ex) { ShowFeedback(ex.Message, FeedbackType.Error); } }
public BaseQandAPageVM(string dbcontextName) : base(dbcontextName) { //Commands SaveFormCmd = new SaveCmd(this); DeleteCmd = new DeleteCmd(this); UploadImageCmd = new UploadImageCmd(this); ToggleMarkQCmd = new ToggleMarkQCmd(this); ToggleMarkACmd = new ToggleMarkACmd(this); CancelCmd = new CancelCmd(this); NewModeCmd = new NewModeCmd(this); PostCmd = new PostCmd(this); DeleteCommentCmd = new DeleteCommentCmd(this); EditCommentCmd = new EditCommentCmd(this); //setup QVisConDTO = new QuestionStateConverterDTO(); AVisConDTO = new AnswerStateConverterDTO(); AnswerSearchTxt = ""; QuestionSearchTxt = ""; rowLimit = 20; openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Select a picture"; openFileDialog.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" + "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "Portable Network Graphic (*.png)|*.png"; Mediator.Register(MediatorChannels.PoolingUpdate.ToString(), PoolingUpdate); }
public FightersList() { _editableData = new FighterData(); Fighters = new ObservableCollection <FighterData>(); FilteredFighters = new ObservableCollection <FighterData>(); Fighters.Add(new FighterData()); Fighters.Add(new FighterData()); Fighters.Add(new FighterData()); SelectedCity = SelectedClub = "*"; ApplyFilter(); _addCmd = new AddCmd(this); _delCmd = new DeleteCmd(this); _saveCmd = new SaveCmd(this); _loadCmd = new LoadCmd(this); Clubs = new ObservableCollection <string> { }; Cities = new ObservableCollection <string> { }; Fighters.CollectionChanged += UpdateClubs; Fighters.CollectionChanged += UpdateCities; UpdateCities(this, null); UpdateClubs(this, null); }
public ViewAViewModel(ITaskEntryService taskService, ITaskEntryRepository taskEntryRepo) { _taskService = taskService; _taskEntryRepo = taskEntryRepo; UpdateCmd.ObservesProperty(() => SelectedTaskEntry); DeleteCmd.ObservesProperty(() => SelectedTaskEntry); }
/// <summary> /// /// </summary> /// <param name="cmdStr"></param> /// <returns></returns> internal static ICmd ParseSqlCmdString(string cmdStr, CoreEA.ICoreEAHander dbe) { ICmd curCmd = null; if (string.IsNullOrEmpty(cmdStr)) { ProcessException.DisplayErrors(new Exception("Empty Command")); return(null); } try { cmdStr = cmdStr.TrimStart(); cmdStr = cmdStr.TrimEnd(); //Can't to lower , otherwise the insert data will never 大写 //cmdText = cmdText.ToLower(); string tempCmdText = cmdStr.ToLower(); if (tempCmdText.StartsWith("select")) { curCmd = new SelectCmd(dbe); } else if (tempCmdText.StartsWith("insert")) { curCmd = new InsertCmd(dbe); } else if (tempCmdText.StartsWith("update")) { curCmd = new UpdateCmd(dbe); } else if (tempCmdText.StartsWith("delete")) { curCmd = new DeleteCmd(dbe); } else if (tempCmdText.StartsWith("alter") || (tempCmdText.StartsWith("drop"))) { curCmd = new SpecialCmd(dbe); } else if (tempCmdText.StartsWith("create")) { curCmd = new CreateCmd(dbe); } else if (tempCmdText.StartsWith("sp_rename")) { curCmd = new SpecialCmd(dbe); } else { curCmd = null; //throw new Exception("ErrorMsg_CannotParseSqlCmd".GetFromResourece()); } } catch (Exception ee) { ProcessException.DisplayErrors(ee); } return(curCmd); }
static void Main(string[] args) { var httplistener = new HttpListener(); try { httplistener.Prefixes.Add("http://*:80/"); httplistener.Start(); Console.WriteLine("server successfully runned"); while (true) { IHttpCommand command; HttpListenerContext httplistenercontext = httplistener.GetContext(); string commandname = httplistenercontext.Request.HttpMethod; switch (commandname) { case WebRequestMethods.Http.Put: command = new PutCmd(); Console.WriteLine("method PUT was called"); break; case DeleteMethod: command = new DeleteCmd(); Console.WriteLine("method DELETE was called"); break; case WebRequestMethods.Http.Head: command = new HeadCmd(); Console.WriteLine("method HEAD was called"); break; case WebRequestMethods.Http.Get: command = new GetCmd(); Console.WriteLine("method GET was called"); break; default: Console.WriteLine("Unrecognized Method!"); httplistenercontext.Response.StatusCode = NotImplemented; httplistenercontext.Response.OutputStream.Close(); continue; } HttpListenerResponse response = httplistenercontext.Response; command.Process(httplistenercontext.Request, ref response); } } catch (Exception ex) { Console.WriteLine(ex); } finally { httplistener.Close(); } Console.ReadLine(); }
protected void DeleteDb(Pipe pipe) { if (pipe == null) { return; } DeleteCmd dcmd = new DeleteCmd(); PipeRev piperev = new PipeRev(); piperev.ListPipe = new List <DBCtrl.DBClass.CPipeInfo>(); piperev.ListPipe.Add(pipe.pipeInfo); dcmd.SetReceiver(piperev); dcmd.Execute(); }
protected void DelDB(Cover c) { if (c == null) { return; } CJuncInfo info = c.juncInfo; DeleteCmd cmd = new DeleteCmd(); JuncRev rev = new JuncRev(); rev.ListJunc = new List <CJuncInfo>(); rev.ListJunc.Add(info); cmd.SetReceiver(rev); cmd.Execute(); }
public override async Task Execute() { var deleteThumb = new DeleteCmd { Key = File.ThumbKey, ContainerName = "thb" }; await CloudHandler.Execute(deleteThumb); if (!deleteThumb.Confirm.Success) { Result = ActionConfirm.CreateFailure("Thumb blob failed to delete -> " + File.Id); return; } var delete = new DeleteCmd { Key = File.UrlKey }; if (File.IsImage) { delete.ContainerName = "ful"; } if (File.IsVideo) { delete.ContainerName = "vid"; } if (File.IsDocument) { delete.ContainerName = "doc"; } await CloudHandler.Execute(delete); var persist = new Delete <VisibleFile> { Id = File.Id }; await DataHandler.Execute(persist); Result = ActionConfirm.CreateSuccess("File deleted"); }
public StudentsPageVM(string dbcontextName, Student selectedStudent, ISystemUser loggedInLectuer) : base(dbcontextName) { try { studentRowsToReturn = 50; IsConfirmed = false; SubgridContext = SubgridContext.Groups; //commands RemoveEntityCmd = new RemoveEntityCmd(this); NewModeCmd = new NewModeCmd(this); SaveFormCmd = new SaveCmd(this); NewPassHashCmd = new NewPassHashCmd(this); MoveEntityOutOfListCmd = new MoveEntityOutOfListCmd(this); MoveEntityInToListCmd = new MoveEntityInToListCmd(this); ChangeSubgridContextCmd = new ChangeSubgridContextCmd(this); DeleteCmd = new DeleteCmd(this); CancelCmd = new CancelCmd(this); GoToEntityCmd = new GoToEntityCmd(this); AnalyseEntityCmd = new AnalyseEntityCmd(this); CSVCmd = new CSVCmd(this); //TODO: will likely need to attach lecturer to the DbContext.. Lecturer = (Lecturer)loggedInLectuer; SearchStudentTxt = ""; if (selectedStudent.Id == 0) { SelectedStudent = new Student(); } else { SelectedStudent = UnitOfWork.StudentRepo.Get(selectedStudent.Id); } //TODO: figure out Async with EF and Pagination/ limit the results (limit probably best) RefreshAvailableGroups(SelectedStudent); List <Student> results = UnitOfWork.StudentRepo.GetAll().ToList(); Students = new ObservableCollection <Student>(results); } catch (Exception ex) { ShowFeedback(ex.Message, FeedbackType.Error); } }
public LemmaRepository(LemmaDatabase db, string tableName, string[] columnNames) { Database = db; TableName = tableName; ColumNames = columnNames; InsertCmd = db.CreateCommand("insert into " + TableName + "(word," + string.Join(",", columnNames) + ") values(@word, @" + string.Join(", @", columnNames) + ")"); InsertCmd.Prepare(); string[] columnSetters = columnNames.Select(x => x + "=@" + x).ToArray(); // x=@x UpdateCmd = db.CreateCommand("update " + TableName + " set word=@word, " + string.Join(", ", columnSetters) + " where id=@id"); UpdateCmd.Prepare(); DeleteCmd = db.CreateCommand("delete from " + TableName + " where id=@id"); DeleteCmd.Prepare(); CountCmd = db.CreateCommand("select count(*) from " + TableName); CountCmd.Prepare(); SelectByIdCmd = db.CreateCommand("select * from " + TableName + " where id=@id"); SelectByIdCmd.Prepare(); SelectPageOfDataCmd = db.CreateCommand("select * from " + TableName + " limit @pageSize offset @offset"); SelectPageOfDataCmd.Prepare(); }
public BaseMySessionsPageVM(string dbcontextName) : base(dbcontextName) { //register commands NewModeCmd = new NewModeCmd(this); SaveFormCmd = new SaveCmd(this); AddLecturerCmd = new AddLecturerCmd(this); RemoveEntityCmd = new RemoveEntityCmd(this); DeleteCmd = new DeleteCmd(this); ChangeSubgridContextCmd = new ChangeSubgridContextCmd(this); GoToEntityCmd = new GoToEntityCmd(this); AnalyseEntityCmd = new AnalyseEntityCmd(this); CancelCmd = new CancelCmd(this); //initial setup try { Mediator.Register(MediatorChannels.PoolingUpdate.ToString(), PoolingUpdate); } catch (Exception ex) { ShowFeedback(ex.Message, FeedbackType.Error); } }
public BaseMyGroupsPageVM(string dbcontextName) : base(dbcontextName) { //Commands SaveFormCmd = new SaveCmd(this); NewModeCmd = new NewModeCmd(this); ChangeSubgridContextCmd = new ChangeSubgridContextCmd(this); DeleteCmd = new DeleteCmd(this); RemoveEntityCmd = new RemoveEntityCmd(this); MoveEntityOutOfListCmd = new MoveEntityOutOfListCmd(this); MoveEntityInToListCmd = new MoveEntityInToListCmd(this); GoToEntityCmd = new GoToEntityCmd(this); AnalyseEntityCmd = new AnalyseEntityCmd(this); CancelCmd = new CancelCmd(this); try { Mediator.Register(MediatorChannels.PoolingUpdate.ToString(), PoolingUpdate); } catch (Exception ex) { ShowFeedback(ex.Message, FeedbackType.Error); } }
static void Main(string[] args) { // CUser user = (CUser)(Assembly.Load(filepath).CreateInstance(filepath + ".DBClass." + "CUser")); // if (user != null) // { // System.Console.WriteLine(user.ToString()); // System.Console.ReadLine(); // } InsertCmd icmd = new InsertCmd(); LoadCmd lcmd = new LoadCmd(); SelectCmd scmd = new SelectCmd(); UpdateCmd ucmd = new UpdateCmd(); DeleteCmd dcmd = new DeleteCmd(); ClearCmd ccmd = new ClearCmd(); #region test TUser // UserRev userrev = new UserRev(); // CUser u = new CUser(); // u.UserName = "******"; // u.UserType = 1; // u.PassWord = "******"; // List<CUser> listuser = new List<CUser>(); // listuser.Add(u); // userrev.ListUser = listuser; // icmd.SetReceiver(userrev); // icmd.Execute(); // lcmd.SetReceiver(userrev); // lcmd.Execute(); // System.Console.WriteLine("Element number:{0}", userrev.ListUser.Count); // userrev.UserName = "******"; // scmd.SetReceiver(userrev); // scmd.Execute(); // System.Console.WriteLine("Element number:{0}", userrev.ListUser.Count); // userrev.ListUser.ElementAt(0).PassWord = "******"; // ucmd.SetReceiver(userrev); // ucmd.Execute(); // dcmd.SetReceiver(userrev); // dcmd.Execute(); // ccmd.SetReceiver(userrev); // ccmd.Execute(); #endregion #region test TSystemBase SystemRev sysrev = new SystemRev(); // CSystemBase sysbase = new CSystemBase(); // sysbase.SystemID = "2014722002"; // sysbase.SysName = "test system name"; // List<CSystemBase> list = new List<CSystemBase>(); // list.Add(sysbase); // sysrev.SysList = list; // icmd.SetReceiver(sysrev); // icmd.Execute(); // lcmd.SetReceiver(sysrev); // lcmd.Execute(); // System.Console.WriteLine(sysrev.SysList.Count); // // dcmd.SetReceiver(sysrev); // dcmd.Execute(); #endregion #region test PumpRev PumpRev prev = new PumpRev(); // CPumpStationInfo pump = new CPumpStationInfo(); // pump.PumpName = "testpum"; // List<CPumpStationInfo> list = new List<CPumpStationInfo>(); // list.Add(pump); // prev.ListPump = list; // icmd.SetReceiver(prev); // icmd.Execute(); // lcmd.SetReceiver(prev); // lcmd.Execute(); // System.Console.WriteLine(prev.ListPump.Count); // prev.PumpName = "testpum"; // scmd.SetReceiver(prev); // scmd.Execute(); // System.Console.WriteLine(prev.ListPump.Count); // prev.ListPump.ElementAt(0).PumpName = "Newname"; // ucmd.SetReceiver(prev); // ucmd.Execute(); // dcmd.SetReceiver(prev); // dcmd.Execute(); // ccmd.SetReceiver(prev); // ccmd.Execute(); #endregion #region test OutFallinfo OutFallRev orev = new OutFallRev(); // COutFallInfo outfall = new COutFallInfo(); // COutFallExtInfo outext = new COutFallExtInfo(); // List<COutFallInfo> listoutfall = new List<COutFallInfo>(); // List<COutFallExtInfo> listoutext = new List<COutFallExtInfo>(); // outfall.Category = 1; // outfall.SystemID = "2014722001"; // listoutfall.Add(outfall); // outext.OutFallName = "outfallname"; // listoutext.Add(outext); // orev.OutList = listoutfall; // orev.OutExtList = listoutext; // icmd.SetReceiver(orev); // icmd.Execute(); // lcmd.SetReceiver(orev); // lcmd.Execute(); // System.Console.WriteLine("OutList Number: {0},OutlistExt NUmber : {1}",orev.OutList.Count,orev.OutExtList.Count); // orev.OutExtList.ElementAt(0).OutFallName = "New Name"; // orev.OutList.ElementAt(0).ReportDept = "adasda"; // ucmd.SetReceiver(orev); // ucmd.Execute(); // dcmd.SetReceiver(orev); // dcmd.Execute(); #endregion #region test junction JuncRev jrev = new JuncRev(); //lcmd.SetReceiver(jrev); //lcmd.Execute(); //Console.WriteLine(jrev.ListJunc.Count); //CJuncInfo junc = new CJuncInfo(); //CJuncExtInfo junext = new CJuncExtInfo(); //List<CJuncInfo> listjunc = new List<CJuncInfo>(); //List<CJuncExtInfo> listjuncext = new List<CJuncExtInfo>(); //junc.Junc_Style = 1; //junc.X_Coor = 119.1232443; //junc.Y_Coor = 21.123023123; //junext.Lane_Way = "way name"; //listjuncext.Add(junext); //listjunc.Add(junc); //listjuncext.Add(junext); //jrev.ListJunc = listjunc; //icmd.SetReceiver(jrev); //icmd.Execute(); jrev.JuncName = "ShiN-W1 / LongQ-W1"; scmd.SetReceiver(jrev); scmd.Execute(); System.Console.WriteLine(jrev.ListJunc.Count); //jrev.ListJunc.ElementAt(0).SystemID = "2102323"; //jrev.ListJuncExt.ElementAt(0).Junc_Class = 2; //ucmd.SetReceiver(jrev); //ucmd.Execute(); //dcmd.SetReceiver(jrev); //dcmd.Execute(); //ccmd.SetReceiver(jrev); //ccmd.Execute(); #endregion #region test pipe PipeRev piperev = new PipeRev(); // lcmd.SetReceiver(piperev); // lcmd.Execute(); // System.Console.WriteLine(piperev.ListPipe.Count); // CPipeInfo pipe = new CPipeInfo(); // pipe.PipeName = "Y2-Y3"; // List<CPipeInfo> listpipe = new List<CPipeInfo>(); // listpipe.Add(pipe); // piperev.ListPipe = listpipe; // icmd.SetReceiver(piperev); // icmd.Execute(); //piperev.PipeName = "Y1-Y2"; //scmd.SetReceiver(piperev); //scmd.Execute(); //System.Console.WriteLine(piperev.ListPipe.Count); //System.Console.WriteLine(piperev.ListPipeExt.Count); //System.Console.WriteLine(piperev.ListUS.Count); //System.Console.WriteLine(piperev.ListLog.Count); //System.Console.WriteLine(piperev.ListVideo.Count); // ucmd.SetReceiver(piperev); // ucmd.Execute(); //piperev.ListLog.Clear(); //piperev.ListPipeExt.Clear(); //dcmd.SetReceiver(piperev); //dcmd.Execute(); #endregion System.Console.WriteLine("Done"); System.Console.ReadLine(); }
private void DeleteEntities_Executed() { var cmd = new DeleteCmd(); Drawing.OnCommand(cmd); }
public void RemoveById(int id) { DeleteCmd.Parameters.Add(Database.CreateParameter("id", id, DeleteCmd)); DeleteCmd.ExecuteNonQuery(); }