public ActionResult New(Taskk task) { task.UserId = User.Identity.GetUserId(); var project = db.Projects.Find(task.ProjectId); task.AssignedUserId = "test"; try { if (project.UserId == User.Identity.GetUserId() || User.IsInRole("Admin")) { db.Tasks.Add(task); db.SaveChanges(); TempData["message"] = "The task has been added!"; return(Redirect("/Projects/Show/" + task.ProjectId)); } else { TempData["message"] = "You are not allowed to add a new Task!"; return(Redirect("/Projects/Show/" + task.Project.ProjectId)); } } catch (Exception) { return(View(task)); } }
public static void NewTargets(IParameters parameters) { Task <string> assets = "assets"; Task <string> compile = Taskk.OnBuild(new { Assets = assets }, args => { return(args.Assets.Value); }); }
//////////////////////////////////////Taskk table//////////////////////////////////////////// public int AddTaskk(Taskk task) { int recentAddedEnterdTask = 0; try { lock (collisionLock) { if (task.TaskTrackId != null) //update record { recentAddedEnterdTask = database.Update(task); return(recentAddedEnterdTask); } else { // enter as new entry recentAddedEnterdTask = database.Insert(task); return(recentAddedEnterdTask); } } } catch (Exception ex) { MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); return(0); } }
public TaskViewModel() { databaseHelper = DatabaseHelper.GetInstance(); database = DependencyService.Get <IDatabaseConnection>().DbConnection(); SortedAndSetTheTaskList(); ItemTapCommand = new Command(async e => { try { selectedTask = (e as Taskk); if (selectedTask.TaskTrackId.Equals(AppConstant.addCustomProductiveTaskTrackId) || selectedTask.TaskTrackId.Equals(AppConstant.addCustomUnProductiveTaskTrackId) || selectedTask.TaskTrackId.Equals(AppConstant.addCustomMiscellaneousTaskTrackId)) { // insert new task OpenAddTaskPopupViewHandler(selectedTask, null); // move control to TaskPage.xaml.cs page to show the input dialog } else { // highlight the selected task currentSelectedTask = selectedTask; // to keep track of selected task HighlightSelectedTask(); bool actionResult = await Application.Current.MainPage.DisplayAlert(null, AppConstant.ConformationMessagetoAddTask, "Yes", "No"); if (actionResult) { OpenCalenderForStatsHandler(selectedTask, null); } } } catch (Exception ex) { MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); } }); }
/// <summary> /// Set up all commands for this page /// provide implementation for every commands of this page /// </summary> private void SetUpCommands() { ItemTapCommand = new Command(async e => { try { selectedTask = (e as Taskk); if (selectedTask.TaskTrackId.Equals(AppConstant.addCustomProductiveTaskTrackId) || selectedTask.TaskTrackId.Equals(AppConstant.addCustomUnProductiveTaskTrackId) || selectedTask.TaskTrackId.Equals(AppConstant.addCustomMiscellaneousTaskTrackId)) { // insert new task OpenAddTaskPopupViewHandler(selectedTask, null); // move control to TaskPage.xaml.cs page to show the input dialog } else { // highlight the selected task currentSelectedTask = selectedTask; // to keep track of selected task HighlightSelectedTask(); bool actionResult = await Application.Current.MainPage.DisplayAlert(null, AppConstant.ConformationMessagetoAddTask, "Yes", "No"); if (actionResult) { OpenCalenderForStatsHandler(selectedTask, null); } } } catch (Exception ex) { MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); } }); }
public ActionResult Show(Comment comm) { comm.CommentDate = DateTime.Now; comm.UserId = User.Identity.GetUserId(); try { if (ModelState.IsValid) { db.Comments.Add(comm); db.SaveChanges(); return(Redirect("/Tasks/Show/" + comm.TaskId)); } else { Taskk task = db.Tasks.Find(comm.TaskId); SetAccessRights(); return(View(task)); } } catch (Exception) { Taskk task = db.Tasks.Find(comm.TaskId); SetAccessRights(); return(View(task)); } }
public Taskk Create(TaskPostModel task) { Taskk toAdd = TaskPostModel.ToTask(task); context.Tasks.Add(toAdd); context.SaveChanges(); return(toAdd); }
// POST api/<controller> public IHttpActionResult Post([FromBody] Taskk model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } repo.Create(model); return(Ok()); }
public Taskk Create(TaskPostModel task, User addedBy) { Taskk toAdd = TaskPostModel.ToTask(task); toAdd.Owner = addedBy; context.Tasks.Add(toAdd); context.SaveChanges(); return(toAdd); }
public void ABC() { Taskk t = new Taskk(); // t.CreatedAt //t.CreatedAt string d = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt"); DateTime dt = Convert.ToDateTime(d); var s = database.Query <Taskk>("SELECT * FROM Taskk WHERE strftime('%m', CreatedAt) IN ('02', '01')"); }
public static TaskGetModel FromTask(Taskk task) { return(new TaskGetModel { Title = task.Title, Description = task.Description, Added = task.Added, Deadline = task.Deadline, ClosedAt = task.ClosedAt }); }
public async void Create(Taskk Taskk) { try { using (Context) { Context.Task.Add(Taskk); await Context.SaveChangesAsync(); } } catch (Exception ex) { Console.Write(ex); } }
public ActionResult Edit(int id) { Taskk task = db.Tasks.Find(id); task.UserNames = GetAllUsers(task.Project.TeamId); if (task.UserId == User.Identity.GetUserId() || User.IsInRole("Admin") || User.IsInRole("User")) { return(View(task)); } else { TempData["message"] = "You are not allowed to edit this Task!"; return(Redirect("/Tasks/Show/" + task.TaskId)); } }
public ActionResult Show(int id) { Taskk task = db.Tasks.Find(id); task.UserNames = GetAllUsers(task.Project.TeamId); ViewBag.ListOfUsers = task.UserNames; if (TempData.ContainsKey("message")) { ViewBag.Message = TempData["message"]; } SetAccessRights(); return(View(task)); }
public Taskk GetLastlyInsertedTask_Taskk() { try { lock (collisionLock) { Taskk task = database.Table <Taskk>().Last(); return(task); } } catch (Exception ex) { MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); return(null); } }
public Taskk UpdateTask(int id, Taskk updatedTask) { Taskk task = GetTaskById(id); if (task == null) { return(null); } task.Title = updatedTask.Title; task.Description = updatedTask.Description; task.IsComplete = updatedTask.IsComplete; db.Tasks.Update(task); db.SaveChanges(); return(GetTaskById(id)); }
// PUT api/<controller>/5 public IHttpActionResult Put(int id, [FromBody] Taskk model) { if (!ModelState.IsValid || id != model.IdTask) { return(BadRequest(ModelState)); } if (repo.FindbyId(id) == null) { return(NotFound()); } else { repo.Update(model); return(Ok()); } }
public CalenderPageView(Taskk selectedTask) { InitializeComponent(); try { calender.MaxDate = DateTime.Now.AddDays(0); calender.MinDate = DateTime.Now.AddDays(-1); calender.Padding = new Thickness(5, Device.RuntimePlatform == Device.iOS ? 25 : 5, 5, 5); dayTasksViewModel = new DayTasksViewModel(); BindingContext = dayTasksViewModel; dayTasksViewModel.CurrentSelectedTaskk = selectedTask; dayTasksViewModel.OpenTaskStatsViewPageHandler += OpenTaskStatsViewPage; }catch (Exception ex) { MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); } }
public DayTasksViewModel() { taskForDayList = new ObservableCollection <CarocelModel>(); taskForDayListForMonth = new ObservableCollection <int>(); currentSelectedTask = new Taskk(); CurrentSelectedDate = DateTime.Now; //Commands Definations DateChosenForAddTaskCommand = new Command(() => { SaveTask(); }); DateChosenForViewTasksCommand = new Command(() => { // OpenTaskStatsViewPageHandler(CurrentSelectedDate.ToString("yyyy-MM-dd"), null); }); }
public ActionResult Delete(int id) { Taskk task = db.Tasks.Find(id); if (task.UserId == User.Identity.GetUserId() || User.IsInRole("Admin")) { db.Tasks.Remove(task); db.SaveChanges(); TempData["message"] = "The task has been deleted!"; return(Redirect("/Projects/Show/" + task.ProjectId)); } else { TempData["message"] = "You are not allowed to delete this Task!"; return(Redirect("/Tasks/Show/" + task.TaskId)); } }
public ActionResult Edit(int id, Taskk requestTask) { try { if (ModelState.IsValid) { Taskk task = db.Tasks.Find(id); if (task.UserId == User.Identity.GetUserId() || User.IsInRole("Admin") || User.IsInRole("User")) { if (TryUpdateModel(task)) { task.TaskName = requestTask.TaskName; task.TaskContent = requestTask.TaskContent; task.TaskDeadline = requestTask.TaskDeadline; task.TaskStatus = requestTask.TaskStatus; task.TaskStartDate = requestTask.TaskStartDate; task.ProjectId = requestTask.ProjectId; db.SaveChanges(); TempData["message"] = "The task has been updated!"; return(Redirect("/Projects/Show/" + task.ProjectId)); } else { return(View(requestTask)); } } else { TempData["message"] = "You are not allowed to edit this Task!"; return(Redirect("/Tasks/Show/" + task.TaskId)); } } else { requestTask.UserNames = GetAllUsers(requestTask.Project.TeamId); return(View(requestTask)); } } catch (Exception) { //requestTask.UserNames = GetAllUsers(requestTask.Project.TeamId); return(View(requestTask)); } }
/// <summary> /// Prepare the new day task to be going to added /// </summary> public void PrePareNewTask() { try { Taskk taskk = databaseHelper.GetTaskkBaseOnTitle(SelectedTask, SelectedTaskType); NewDayTask.TaskType = SelectedTaskType; NewDayTask.IsSelected = false; NewDayTask.TaskTitle = SelectedTask; NewDayTask.RefTaskTrackId = taskk.TaskTrackId; NewDayTask.BGColor = taskk.BGColor; NewDayTask.DayTaskTrackId = null; NewDayTask.UpdatedAt = AppUtil.AppUtil.CurrrentDateTimeInSqliteSupportedFormate(); NewDayTask.TaskStartedAt = StartTime.ToString("yyyy-MM-dd hh:mm:ss tt"); NewDayTask.CreatedAt = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); }catch (Exception ex) { MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { Logic lo = new Logic(); Taskk t = new Taskk(); t.Title = txtTitle.Text; t.Description = txtDescription.Text; t.IsComplete = true; int taskid=lo.GetTaskID(drpTitles.SelectedItem.Text); if (lo.UpdateTask(t, taskid)) { Label lb = new Label(); lb.Text = "Task Updated Successfully"; Panel1.CssClass = "divSuccess"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/success3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } else if (lo.UpdateTask(t, taskid)) { Label lb = new Label(); lb.Text = "Task Update Failed"; Panel1.CssClass = "divError"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/error3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } } catch { Label lb = new Label(); lb.Text = "Update Failed. Please Try Again"; Panel1.CssClass = "divError"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/error3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } }
private void btnAdd_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(textDesription.Text) && !string.IsNullOrWhiteSpace(textDesription.Text)) { try { var res = root.Elements("task").Where(t => t.Attribute("title").Value == textTitle.Text).FirstOrDefault(); // MessageBox.Show(res.Value); if (res == null) { Taskk newTask = new Taskk() { Title = textTitle.Text, Description = textDesription.Text, Deadline = dateTimeDeadline.Value.ToString() }; xd.Element("root").Add(new XElement("task", new XAttribute("title", newTask.Title), new XAttribute("description", newTask.Description), new XAttribute("deadline", newTask.Deadline))); xd.Save(path); loadTaskList(); Form1 fm = new Form1(); fm.loadVoiceLines(); fm.playVoiceLine(0); } else { MessageBox.Show("Такое задание уже существует"); } } catch (Exception err) { MessageBox.Show(err.Message); } } else { MessageBox.Show("Вы не ввели значения"); } }
public async void Update(Taskk Taskk) { try { using (Context) { var update = FindbyId(Taskk.IdTask); update.IdFeedback = Taskk.IdFeedback; update.NameTask = Taskk.NameTask; update.DescriptionTask = Taskk.DescriptionTask; update.TaskStart = Taskk.TaskStart; update.TaskEnd = Taskk.TaskEnd; await Context.SaveChangesAsync(); } } catch (Exception ex) { Console.Write(ex); } }
public Taskk Upsert(int id, Taskk task) { var existing = context.Tasks.AsNoTracking().FirstOrDefault(f => f.Id == id); if (existing == null) { context.Tasks.Add(task); context.SaveChanges(); return(task); } task.Id = id; // 3. Editing the State of a Task,if it is closed => closedAt == time of request, else null // Edited DateTime to Nullable<DateTime> https://www.dotnetperls.com/nullable-datetime task.ClosedAt = (task.State.Equals(Models.TaskState.Closed)) ? DateTime.Now : (DateTime?)null; context.Tasks.Update(task); context.SaveChanges(); return(task); }
public ActionResult New(int id) { Taskk task = new Taskk(); task.ProjectId = id; var project = db.Projects.Find(id); task.AssignedUserId = "test"; ViewBag.ProjectTitle = project.ProjectTitle; if (project.UserId == User.Identity.GetUserId() || User.IsInRole("Admin")) { // task.Projects = GetAllProjects(); task.UserId = User.Identity.GetUserId(); return(View(task)); } else { TempData["message"] = "You are not allowed to add a new Task!"; return(Redirect("/Projects/Show/" + project.ProjectId)); } }
private void loadTaskList() { listBoxTasks.Items.Clear(); var tasks = root.Elements("task").ToList(); if (tasks.Count != 0) { Taskk t = null; foreach (var task in tasks) { t = new Taskk() { Title = task.Attribute("title").Value, Description = task.Attribute("description").Value, Deadline = task.Attribute("deadline").Value }; listBoxTasks.Items.Add(t); } listBoxTasks.DisplayMember = t.ToString(); } }
public Taskk GetTaskBasesOnSpecificId(string trackId) { try { lock (collisionLock) { if (trackId != null) { Taskk task = database.Table <Taskk>().First(x => x.TaskTrackId == trackId); return(task); } else { return(null); } } } catch (Exception ex) { // MessagingCenter.Send((App)Xamarin.Forms.Application.Current, AppConstant.ErrorEvent, ex.ToString()); return(null); } }
/// <summary> /// open the popup page to add new task /// pass the Id of Selected task as paprameter to to tell the AddTaskPopup page which type of task it need to insert /// </summary> /// <param name="sender">Clicked task </param> /// <param name="e"></param> private async void ShowAddTaskPopUpAsync(object sender, EventArgs e) { Taskk selectedTask = sender as Taskk; await Navigation.PushPopupAsync(new AddAndEditTasksPopUpViewPage(selectedTask.TaskTrackId)); }
public IActionResult Put(int id, [FromBody] Taskk Task) { var result = taskService.Upsert(id, Task); return(Ok(result)); }
protected void btnSubmit_Click(object sender, EventArgs e) { Logic lo = new Logic(); Taskk t = new Taskk(); t.Title = tasktitle.Value; t.Description = taskdesc.Value; t.IsComplete = false; //DateTime.Parse(Calendar1.SelectedDate) if (tasktitle.Value.Length == 0 || taskdesc.Value.Length == 0) { Label lb = new Label(); lb.Text = "Empty Fields Are Not Allowed"; Panel1.CssClass = "divError"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/error3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } else if (tasktitle.Value.Length != 0 && taskdesc.Value.Length != 0) { if (Calendar1.SelectedDate != null) { t.DateCreated = (DateTime)Calendar1.SelectedDate; bool resp1 = lo.CreateTask(t); int last = lo.GetLastTaskID(); PersonTask pt = new PersonTask(); string u = Session["username"].ToString(); Person pp = lo.GetPerson(u); pt.PersonId = pp.Id; //lo.GetPersonID("ay"); pt.TaskkId = last; bool resp2 = lo.CreatePersonTask(pt); if (resp1 == true && resp2 == true) { Label lb = new Label(); lb.Text = "New Task Added Successfully"; Panel1.CssClass = "divSuccess"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/success3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } else if (resp1 != true || resp2 != true) { Label lb = new Label(); lb.Text = "New Task Could Not Be Added"; Panel1.CssClass = "divError"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/error3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } } else if (Calendar1.SelectedDate == null) { Label lb = new Label(); lb.Text = "No Date Selected"; Panel1.CssClass = "divError"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/error3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } } }