public void TasksModelPropertiesTest() { //arrange int tasks_model_id = 1; string tasks_model_name = "Task1"; string tasks_model_description = "DescriptionTask1"; string tasks_model_set_id = "2"; string tasks_model_ordr = "1"; //act TasksModel tasksModel = new TasksModel(); tasksModel.TaskId = tasks_model_id; tasksModel.TaskName = tasks_model_name; tasksModel.TaskDescription = tasks_model_description; tasksModel.TaskSetId = tasks_model_set_id; tasksModel.Ordr = tasks_model_ordr; //assert Assert.AreEqual(tasks_model_id, tasksModel.TaskId, "TaskId incompatibility"); Assert.AreEqual(tasks_model_name, tasksModel.TaskName, "TaskName incompatibility"); Assert.AreEqual(tasks_model_description, tasksModel.TaskDescription, "TaskDescription incompatibility"); Assert.AreEqual(tasks_model_set_id, tasksModel.TaskSetId, "TaskSetId incompatibility"); Assert.AreEqual(tasks_model_ordr, tasksModel.Ordr, "Ordr incompatibility"); }
public CreateTaskPage() { tasks = new TasksModel(); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; SystemNavigationManager.GetForCurrentView().BackRequested += onBackBtnClick; this.InitializeComponent(); }
public async Task <string> GetDate(int ID) { try { using (HttpClient client = new HttpClient()) { TasksModel tsk = new TasksModel(); using (HttpResponseMessage response = await client.GetAsync(ConfigurationManager.AppSettings["MySeverUrl"] + "/api/GetDate/ID=" + ID)) { if (response.IsSuccessStatusCode) { using (HttpContent content = response.Content) { var textresponse = await content.ReadAsStringAsync(); var json = JsonConvert.DeserializeObject <TasksModel>(textresponse); tsk.tasDue_Date_String = json.tasDue_Date_String; } return(tsk.tasDue_Date_String); } else { return(""); } } } } catch (Exception) { return(""); } }
protected void Page_Load(object sender, EventArgs e) { string check; check = Convert.ToString(Session["loginAdmin"]); if (check != "admin") { Response.Redirect("~/Login.aspx"); } if (!IsPostBack) { Session["CheckEdit"] = "false"; DropDownListImageAndName(); ImageCaption.ImageUrl = "~/Uploads/IssueImages/NoImage.png"; if (Request.QueryString["Id"] != null && Request.QueryString["Id"] != "") { string IsUpdated = Convert.ToString(Session["IsUpdated"]); if (IsUpdated == "Updated") { Label1.Text = "Task Successfully Updated!"; Session["IsUpdated"] = "NotUpdated"; Label1.ForeColor = System.Drawing.Color.Green; } int ID = Convert.ToInt32(Request.QueryString["Id"]); TasksModel list = Logic.ListViewTasks(ID); TextBoxName.Text = list.Name; TextBoxDiscription.InnerText = list.Discription; ImageCaption.ImageUrl = list.ImageLink; DropDownListAssignee.SelectedValue = Convert.ToString(list.Email); DropDownListPriority.SelectedValue = list.Priority; Session["CheckEdit"] = "true"; } } }
private void SaveCameraConfigurations(uint taskID) { var directory = TasksModel.GenerateSavedTaskPath(taskID); // Create directory if it doesn't exist: if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } // Serialize cameras: var data = new MemoryStream(); CameraManager.Serialize(new BinaryWriter(data)); // Write to file: var file = directory + "Cameras.data"; using (var stream = File.OpenWrite(file)) { using (var binaryStream = new BinaryWriter(stream)) { binaryStream.Write(data.ToArray(), 0, (int)data.Length); } } }
public async Task <ActionResult> TaskDetails(int id) { TasksModel tsk = new TasksModel(); try { int useID = 0; Users item; if (Session["useDetails"] != null) { item = Session["useDetails"] as Users; useID = item.useID; } ViewBag.UserID = useID; tsk = await taskVm.TaskDetails(id); //tsk.Images = await taskVm.GetImagesForTask(id); } catch (Exception) { //TempData["Message"] = "Unable to process request !"; } return(View(tsk)); }
public async Task <ActionResult> GetStatus(int taskID) { TasksModel ts = new TasksModel(); var response = await taskVm.TaskDetails(taskID); return(View(response)); }
public IActionResult CreateTask(TasksModel task) { if (ModelState.IsValid) { task.TaskId = Guid.NewGuid().ToString("n"); if (task.AssignedTo != null) { var taskId = task.TaskId; var find = db.Users.Where(c => c.UserId == task.AssignedTo).FirstOrDefault(); TaskRequest model = new TaskRequest(); model.TaskId = taskId; model.UserId = find.UserId; model.RequestDate = DateTime.UtcNow; model.DeadLine = task.DeadLine; model.Status = "Not Confirmed"; model.Description = task.Description; db.TaskRequests.Add(model); db.SaveChanges(); var token = JwtToken.GenerateToken(find.UserId, taskId, find.Email); var confirmationLink = Url.Action("ConfirmTask", "Task", new { Areas = "Administration", userId = find.UserId, token = token }, Request.Scheme); var To = find.Email; mailHelper.Send(To, confirmationLink); } db.Tasks.Add(task); db.SaveChanges(); ViewBag.Message = "Added Succesfully"; return(RedirectToAction(nameof(ListTask))); } ViewBag.Message = "Cannot Process. Try Again"; return(View()); }
// GET: Tasks public async Task <ActionResult> Tasks() { var cmpID = 0; Users item = new Users(); if (Session["useDetails"] != null) { item = Session["useDetails"] as Users; } TasksModel model = new TasksModel(); cmpID = item.useCompanyID; List <TypeModel> typModel = new List <TypeModel>(); List <Users> usrModel = new List <Users>(); List <Users> toModel = new List <Users>(); List <PriorityModel> ptyModel = new List <PriorityModel>(); List <StatusModel> staModel = new List <StatusModel>(); UserContext useContext = new UserContext(); TypeContext typContext = new TypeContext(); PriorityContext ptyContext = new PriorityContext(); StatusContext staContext = new StatusContext(); usrModel = await usVM.GetUserConnection(cmpID); //toModel = useContext.ToUsersDropDown(cmpID); typModel = typContext.TypeDropDown(); ptyModel = ptyContext.PriorityDropDown(); staModel = staContext.StatusDropDown(); foreach (var user in usrModel) { model.Users.Add(new SelectListItem { Text = user.useName, Value = user.useID.ToString() }); } //foreach (var user in toModel) //{ // model.ToUsers.Add(new SelectListItem { Text = user.useName, Value = user.useID.ToString() }); //} foreach (var type in typModel) { model.Types.Add(new SelectListItem { Text = type.typName, Value = type.typID.ToString() }); } foreach (var priority in ptyModel) { model.Priorites.Add(new SelectListItem { Text = priority.ptyName, Value = priority.ptyID.ToString() }); } foreach (var status in staModel) { model.Status.Add(new SelectListItem { Text = status.staName, Value = status.staID.ToString() }); } return(View(model)); }
public bool UpdateTask(TasksModel tsk) { ParentTasks pt = new ParentTasks(); pt.ParentID = tsk.ParentID; pt.ParentTaskName = tsk.ParentTaskName; Tasks t = new Tasks(); t.TaskID = tsk.TaskID; t.TaskName = tsk.TaskName; t.Priority = tsk.Priority; t.ParentID = pt.ParentID; if (tsk.StartDate.HasValue) { t.StartDate = tsk.StartDate.Value; } if (tsk.EndDate.HasValue) { t.EndDate = tsk.EndDate.Value; } //t.StartDate = DbFunctions.TruncateTime(tsk.StartDate.Value.Date); //t.EndDate = DbFunctions.TruncateTime(tsk.EndDate.Value.Date); //db.Entry(pt).State = EntityState.Modified; //db.MarkAsModified(t); //db.SaveChanges(); //db.Entry(t).State = EntityState.Modified; db.MarkAsModified(t); db.SaveChanges(); return(true); }
public ActionResult Edit(int id) { if (!CurrentUser.IsManager) { return(RedirectToAction("NotFound", "Home")); } var item = TaskBO.GetById(id); TasksModel model; if (item != null) { model = new TasksModel { Id = item.Id, ProjectId = item.ProjectId, Name = item.Name, Description = item.Description, Priority = item.Priority, StartDate = item.StartDate, EndDate = item.EndDate, Leader = item.Leader, StartAndEndDate = item.StartDate.ToString(Helper.FormatDate) + " - " + item.EndDate.ToString(Helper.FormatDate), DocumentIds = string.Empty, Documents = new List <Document>() }; } else { return(RedirectToAction("NotFound", "Home")); } PreparingData(); return(View("Create", model)); }
/// <summary> /// Fetch Tasks details. /// Extracts Tasks details from the XML response and binds data to observable collection. /// </summary> public async Task <ObservableCollection <TasksModel> > LoadTasksData(string AccessToken) { var TasksResponseBody = await HttpRequestBuilder.Retrieve(AccessToken, new string[] { "Subject", "ScheduledStart" }, "TaskSet"); Tasks = new ObservableCollection <TasksModel>(); // Feed namespace XNamespace rss = "http://www.w3.org/2005/Atom"; // d namespace XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices"; // m namespace XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"; // Convert the string response to an xDocument. XDocument xdoc = XDocument.Parse(TasksResponseBody.ToString(), LoadOptions.None); foreach (var entry in xdoc.Root.Descendants(rss + "entry").Descendants(rss + "content").Descendants(m + "properties")) { TasksModel task = new TasksModel(); task.Subject = entry.Element(d + "Subject").Value; task.ScheduledStartDate = DateTime.Parse(entry.Element(d + "ScheduledStart").Value); Tasks.Add(task); } return(Tasks); }
/// <summary> /// Fetch Tasks details. /// Extracts Tasks details from XML response and binds data to Observable Collection. /// </summary> public async Task <ObservableCollection <TasksModel> > LoadTasksData(string AccessToken) { var TasksResponseBody = await HttpRequestBuilder.RetrieveMultiple(AccessToken, new string[] { "subject", "scheduledstart" }, "task"); Tasks = new ObservableCollection <TasksModel>(); // Converting response string to xDocument. XDocument xdoc = XDocument.Parse(TasksResponseBody.ToString(), LoadOptions.None); XNamespace s = "http://schemas.xmlsoap.org/soap/envelope/"; //Envelop namespace s XNamespace a = "http://schemas.microsoft.com/xrm/2011/Contracts"; //a namespace XNamespace b = "http://schemas.datacontract.org/2004/07/System.Collections.Generic"; //b namespace foreach (var entity in xdoc.Descendants(s + "Body").Descendants(a + "Entities").Descendants(a + "Entity")) { TasksModel task = new TasksModel(); foreach (var KeyvaluePair in entity.Descendants(a + "KeyValuePairOfstringanyType")) { if (KeyvaluePair.Element(b + "key").Value == "subject") { task.Subject = (string)KeyvaluePair.Element(b + "value").Value; } else if (KeyvaluePair.Element(b + "key").Value == "scheduledstart") { task.ScheduledStartDate = DateTime.Parse(KeyvaluePair.Element(b + "value").Value); } } Tasks.Add(task); } return(Tasks); }
public async Task <ActionResult> Test(string date) { var item = Session["useDetails"] as Users; int month = 0; if (string.IsNullOrWhiteSpace(date)) { month = 0; } else { month = Convert.ToInt32(date); } TasksModel task = new TasksModel(); List <TasksModel> taskModel = new List <TasksModel>(); taskModel = await rpVM.GetReports(item.useCompanyID, month); task = new TasksModel { Items = taskModel, }; return(View(task)); }
public async Task <IResponseModel> AddTaskAsync(TasksModel obj) { try { var tasks = new Tasks { Id = Guid.NewGuid(), Title = obj.Title, Description = obj.Description, AssigneeId = obj.AssigneeId, Status = false, DateCreated = DateTime.UtcNow, IsPriority = obj.IsPriority, ProjectId = obj.ProjectId }; _db.Tasks.Add(tasks); await _db.SaveChangesAsync(); _response.Status = true; _response.Message = "Task successfully added."; return(_response); } catch (Exception ex) { _response.Status = false; _response.Message = ex.Message; return(_response); } }
public ActionResult Create(TaskViewModel tasksModel) { if (ModelState.IsValid) { var newTask = new TasksModel() { TasksModelID = tasksModel.TaskId, Heading = tasksModel.Heading, Content = tasksModel.Content, StartDate = tasksModel.StartDate, CreatedBy = User.Identity.GetUserName(), CreatedOn = DateTime.Now, EndDate = tasksModel.EndDate, Status = tasksModel.Status }; db.TasksModels.Add(newTask); db.SaveChanges(); foreach (var item in tasksModel.Users) { if (item.Checked) { db.TaskToUsers.Add(new TaskToUser() { UserIdInt = item.Id, TasksModelID = newTask.TasksModelID }); } } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tasksModel)); }
public void AddTaskTest3() { DateTime date; date = DateTime.Parse("16.02.1999 00:00:00"); TasksModel model = new TasksModel("TestTask3", date, 0); AddTask newTask = new AddTask(); newTask.Add(model, connection); var cmdText = $"SELECT * FROM Tasks WHERE [End_Date] = @EndDate " + $"AND [Task] = '{model.Task}' " + $"AND [Preority] = {model.Preority}"; connection.Open(); OleDbCommand TestCommand = new OleDbCommand(cmdText, connection); TestCommand.Parameters.Add(new OleDbParameter("@EndDate", OleDbType.Date)); TestCommand.Parameters["@EndDate"].Value = model.EndDate; if (TestCommand.ExecuteReader().HasRows) { connection.Close(); Assert.Pass(); } else { connection.Close(); Assert.Fail("В таблице нет записи"); } }
/// <summary> /// Used for correctly relocating people, depending on their access level. /// </summary> /// <returns></returns> public IActionResult RelocateUser() { if (HttpContext.Session.GetInt32("accessLevel") > 1) { // The Task view: For the actions that the SKP Students in the hardware room needs to take today. DBManagerTask DBTasker = new DBManagerTask(configuration); TasksModel tasks = new TasksModel( // bookingsToBeRetrieved DBTasker.GetBookingRetrievalsToBeMade(), // bookingsToBeDelivered DBTasker.GetBookingDeliveriesToBeMade() ); return(View("Task", tasks)); } else if (HttpContext.Session.GetInt32("accessLevel") == 1) { return(View("Main")); } else { return(Logout()); } }
private void LoadCameraConfigurations(uint taskID) { var directory = TasksModel.GenerateSavedTaskPath(taskID); // Create directory if it doesn't exist: if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } // Read file: var file = directory + "Cameras.data"; if (File.Exists(file)) { MemoryStream data; using (var stream = File.OpenRead(file)) { using (var binaryStream = new BinaryReader(stream)) { var bytes = binaryStream.ReadBytes((int)stream.Length); data = new MemoryStream(bytes); } } // Deserialize object: CameraManager.Deserialize(new BinaryReader(data)); } }
public async Task <IActionResult> Edit(int id, [Bind("TaskId,WeekDay,Description,DtCreated,IsActive")] TasksModel tasksModel) { if (id != tasksModel.TaskID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tasksModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TasksModelExists(tasksModel.TaskID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tasksModel)); }
public void OnApplicationQuit() { TasksModel.Save(); // Unset task ID, in order to proper save the configurations: CurrentTaskID = NullID; }
public async Task <JsonResult <TasksModel> > GetTaskByID(int id) { //EntityMapper<Tasks, TasksModel> mapObj = new EntityMapper<Tasks, TasksModel>(); //TaskService taskService = new TaskService(dbContext); taskService = new TaskService(dbContext); Tasks dalTask = await taskService.GetTask(id); TasksModel Tasks = new TasksModel(); if (dalTask != null) { Tasks.Task_ID = dalTask.Task_ID; Tasks.Task = dalTask.Task; Tasks.Parent_ID = dalTask.Parent_ID; Tasks.ParentTask = dalTask.ParentTask != null ? dalTask.ParentTask.Parent_Task : ""; Tasks.Start_Date = dalTask.Start_Date; Tasks.End_Date = dalTask.End_Date; Tasks.Priority = dalTask.Priority; Tasks.Project_ID = dalTask.Project_ID; Tasks.Project = dalTask.Projects != null ? dalTask.Projects.Project : ""; Tasks.User_ID = dalTask.User_ID; Tasks.Name = dalTask.Users != null ? dalTask.Users.FirstName + " " + dalTask.Users.LastName : ""; Tasks.TaskStatus = dalTask.TaskStatus; } else { throw new Exception("Task not available"); } //Tasks = mapObj.Translate(dalTask); //AutoMapper.Mapper.Map(dalTask, Tasks); return(Json <TasksModel>(Tasks)); }
public async Task <ActionResult> PartialImages(int taskID) { TasksModel tsk = new TasksModel(); tsk.Images = await taskVm.GetImagesForTask(taskID); return(View(tsk)); }
public async Task <TasksModel> GetTasks(int pageSize, int pageIndex, SearchTask searchModel = null) { var tasksModel = new TasksModel(); var tasks = await _taskManager.GetTasks(pageSize, pageIndex, searchModel); tasksModel.Tasks = _mapper.Map <List <AdminTask>, List <TaskModel> >(tasks); return(tasksModel); }
//public ActionResult GenerateModel(int id,bool compile=true) //{ // string output = ""; // var message = string.Empty; // var success = false; // try // { // DoGenerate(id,out output,compile); // if (compile) // { // StateHelper.SetGeneratedMappings(); // StateHelper.UpdateAnalyzerMappings(); // } // success = true; // } // catch (Exception ex) { // message = ex.Message; // } // return Json(new{message=message,success=success,Output=output}); //} //private void DoGenerate(int id,out string cs_source,bool compile=true) { // var gm = this.repo.GetGeneratedModel().Where(x => x.ID == id).FirstOrDefault(); // var currentClassName = gm.CName; // var itemplate = System.IO.File.ReadAllText(ApiHelper.MapPath("~/app_data/generated/i_template.txt")); // var cstemplate = System.IO.File.ReadAllText(ApiHelper.MapPath("~/app_data/generated/cs_template.txt")); // var stamp = DateTime.Now; // var stampstr = stamp.ToString("yyyyMMddHHmmss"); // var iname = string.Concat("I_", ApiHelper.SanitizeClassName(gm.Name), "_", stampstr); // var cname = string.Concat(ApiHelper.SanitizeClassName(gm.Name), "_", stampstr); // var sourceBasePath = string.Concat("~/app_data/generated/"); // var sourceVIBasePath = string.Concat(sourceBasePath, "abstract/"); // var sourceVBasePath = string.Concat(sourceBasePath, "concrete/"); // var sourceVIPath = string.Concat(sourceVIBasePath, iname, ".dll"); // var sourceVPath = string.Concat(sourceVBasePath, cname, ".dll"); // var sourcePIPath = HttpContext.Server.MapPath(sourceVIPath); // var sourcePPath = HttpContext.Server.MapPath(sourceVPath); // new FileInfo(sourcePPath).Directory.Create(); // /* // var gen_interfaces = AppDomain.CurrentDomain // .GetAssemblies() // .SelectMany(x => x.GetTypes()).Where(x => x.IsInterface && typeof(I_Generated).IsAssignableFrom(x) && x!=typeof(I_Generated) ); // */ // /* // var interfaceg = gen_interfaces // .Where(x => x.FullName.Equals(string.Concat("puck.Generated.Abstract.I_",gm.Name))).FirstOrDefault(); // */ // Type interfaceg; // if (compile) // { // if (gm.IFullName == null) // { // new FileInfo(sourcePIPath).Directory.Create(); // var isource = itemplate // .Replace("//{interfacename}", string.Concat(iname)) // .Replace("//{baseinterface}", string.Concat("I_Generated")) // .Replace("//{name}", gm.Name); // var iassembly = CodeGenerator.PuckCompiler.CompileCode(isource); // System.IO.File.Copy(iassembly.Location, sourcePIPath, true); // interfaceg = iassembly.GetTypes().First(); // gm.IFullPath = sourceVIPath; // gm.IFullName = interfaceg.AssemblyQualifiedName; // } // else // { // interfaceg = ApiHelper.GetType(gm.IFullName); // iname = interfaceg.Name; // } // } // var properties = new StringBuilder(); // var propList = gm.Properties.ToList(); // foreach (var prop in propList) // { // var propertyEntry = GeneratorValues.PropertyType[prop.Type]; // prop.Attributes.ToList().ForEach(x => { // try // { // I_GeneratedOption opt = JsonConvert.DeserializeObject(x.Value, ApiHelper.GetType(x.Type)) as I_GeneratedOption; // properties.AppendLine( // opt.OutputString() // ); // } // catch (Exception ex) { // var exx = new Exception("error rendering attribute - "+x.ID,ex); // log.Log(ex); // } // }); // var uiHint = propertyEntry.Type.GetCustomAttributes(typeof(PuckHint), false).FirstOrDefault() as PuckHint; // if (uiHint != null && !string.IsNullOrEmpty(uiHint.Name)) // { // properties.AppendLine(string.Format("[UIHint(\"{0}\")]", uiHint.Name)); // } // properties.AppendLine(string.Format("[DisplayName(\"{0}\")]",prop.Name)); // properties.AppendLine(propertyEntry.AttributeString); // properties.AppendLine( // string.Concat("public ", propertyEntry.Type.FullName, " ", ApiHelper.SanitizePropertyName(prop.Name), "{get;set;}") // ); // }; // var inherits = "BaseModel"; // if (!string.IsNullOrEmpty(gm.Inherits)) // { // var inheritedType = ApiHelper.GetType(gm.Inherits); // inherits = inheritedType.Name; // if (!string.IsNullOrEmpty(gm.CName)) // { // var modelType = ApiHelper.GetType(gm.CName); // var baseTypesForInheritedType = ApiHelper.BaseTypes(inheritedType); // if (baseTypesForInheritedType.Contains(modelType)) // throw new Exception("circular inheritance chain detected"); // } // } // var source = cstemplate // .Replace("//{classname}", string.Concat(cname)) // .Replace("//{baseclass}", string.Concat(inherits)) // .Replace("//{interface}", string.Concat(iname)) // .Replace("//{properties}", properties.ToString()) // .Replace("//{name}", gm.Name); // cs_source = source; // if (compile) // { // var assembly = CodeGenerator.PuckCompiler.CompileCode(source); // System.IO.File.Copy(assembly.Location, sourcePPath, true); // var ctype = assembly.GetTypes().First(); // gm.CFullPath = sourceVPath; // gm.CName = ctype.AssemblyQualifiedName; // repo.SaveChanges(); // //get all models which inherit from current edited model, they need to be updated // var models = repo.GetGeneratedModel().Where(x => x.Inherits.Equals(currentClassName)).ToList(); // //order by least amount of dependencies // models = models // .OrderBy(x => // repo.GetGeneratedModel().Where(xx => xx.Inherits.Equals(x.CName)).Count()) // .ToList(); // foreach (var m in models) // { // string output = ""; // m.Inherits = gm.CName; // repo.SaveChanges(); // DoGenerate(m.ID, out output); // } // } //} //public ActionResult PreviewEditor(string type) { // var cstemplate = System.IO.File.ReadAllText(HttpContext.Server.MapPath("~/app_data/generated/cs_template.txt")); // var propertyEntry = GeneratorValues.PropertyType[type]; // var reg = new Regex("using\\s[a-zA-Z0-9\\.]+;"); // var matches = reg.Matches(cstemplate); // var uses = ""; // for(var i=0;i < matches.Count;i++) { // uses += matches[i].Value; // } // var source = string.Format("{0} \n public class test_{1} {{ {2} public {3} Preview {{ get;set; }} }}", // uses,DateTime.Now.ToString("yyyyMMddHHmmss"),propertyEntry.AttributeString,propertyEntry.Type); // var assembly = CodeGenerator.PuckCompiler.CompileCode(source); // var t = assembly.GetTypes().First(); // var instance = Activator.CreateInstance(t); // return View(instance); //} // // GET: /puck/Task/ public ActionResult Index() { var model = new TasksModel(); model.Tasks = apiHelper.Tasks(); //model.GeneratedModels = repo.GetGeneratedModel().ToList(); return(View(model)); }
public async Task <ActionResult> CreateTask() { try { TasksModel task = new TasksModel(); List <ImagesModel> img = new List <ImagesModel>(); HttpFileCollectionBase files = Request.Files; int taskTo = Convert.ToInt32(Request["taskTo"]); int taskFrom = Convert.ToInt32(Request["taskFrom"]); DateTime date = Convert.ToDateTime(Request["date"]); int type = Convert.ToInt32(Request["type"]); int priority = Convert.ToInt32(Request["priority"]); string title = Request["title"].ToString(); string desc = Request.Unvalidated["desc"].ToString(); task.tasDelegatedTo = taskTo; task.tasDelagatedBy = taskFrom; task.tasDue_Date = date; task.tasType = type; task.tasPriority = priority; task.tasTitle = title; task.Description = desc; if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { byte[] bytes; using (BinaryReader br = new BinaryReader(files[i].InputStream)) { bytes = br.ReadBytes(files[i].ContentLength); } img.Add(new ImagesModel { imgImage_Name = files[i].FileName, imgImage_Type = files[i].ContentType, imgImage_Image = bytes, imgType = 2, }); } task.Images = img; } var response = await taskVm.AddTask(task); if (response) { return(Json(new { success = true, responseText = "Yay!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, responseText = "Ahhh!" }, JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(new { success = false, responseText = "Please Complete all required (*) form fields!" }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> GetDate(int taskID) { var response = await taskVm.GetDate(taskID); TasksModel tm = new TasksModel(); tm.tasDue_Date_String = response; return(View(tm)); }
public DashboardPageDetails(TasksModel tasksModel) { InitializeComponent(); TaskId.Text = tasksModel.TaskId.ToString(); TaskTitle.Text = tasksModel.TaskTitle.ToString(); ClientID.Text = tasksModel.ClientID.ToString(); MyList.ItemsSource = tasksModel.clientTasks; }
private void Tasks_Click_Outflow(object sender, RoutedEventArgs e) { TasksOut TM = new TasksOut(); TasksModel tm = new TasksModel(); TM.WindowStartupLocation = WindowStartupLocation.CenterScreen; TM.DataContext = tm; TM.Show(); }
static void AddNewTaskToServer(HttpClient client, TasksModel.Task newTask) { String serializedTask = JsonConvert.SerializeObject(newTask); StringContent content = new StringContent(serializedTask); client.PostAsync("http://localhost:59796/api/v1/tasks", content).Wait(); GetAndPrintAllTasksFromServer(client); }
public ActionResult Create(TasksModel model) { if (!CurrentUser.IsManager) { return(RedirectToAction("NotFound", "Home")); } if (!string.IsNullOrEmpty(model.Name)) { var task = new Task(); task.ProjectId = model.ProjectId; task.Leader = model.Leader; task.Name = model.Name; task.Priority = model.Priority; task.Description = model.Description; task.CreateBy = CurrentUser.Id; task.ModifyBy = CurrentUser.Id; task.CreateDate = DateTime.Now; task.ModifyDate = DateTime.Now; if (!string.IsNullOrEmpty(model.StartAndEndDate) && model.StartAndEndDate.Split('-').Length == 2) { var strStart = model.StartAndEndDate.Split('-')[0].Trim(); var strEnd = model.StartAndEndDate.Split('-')[1].Trim(); DateTime sdate; DateTime edate; if (DateTime.TryParseExact(strStart, Helper.FormatDate, new CultureInfo("en-US"), DateTimeStyles.None, out sdate)) { task.StartDate = sdate; } if (DateTime.TryParseExact(strEnd, Helper.FormatDate, new CultureInfo("en-US"), DateTimeStyles.None, out edate)) { task.EndDate = edate; } TaskBO.Insert(task); var department = DepartmentBO.GetById(task.Leader); if (department != null && department.UserId > 0) { AlertBO.Insert(task.Name, (int)AlertType.Task, 0, department.UserId); } //TODO ... Insert document } return(RedirectToAction("Index")); } PreparingData(); return(View(model)); }
static void UpdatePriorityAndStatusOfTheTask(TasksModel.Task task, TasksModel.Task.TaskState newState, int newPriority) { }