/// <summary> /// Save the unaassigned tasks /// </summary> /// <param name="todo"></param> public void SaveUnAssignedTasks(ListTeamViewModel todo) { int loggedUserId = 0; if (AccountController.uName != null) { User_TuTU user = db.UserTu_Tu.Where(ac => ac.name.Equals(AccountController.uName)).FirstOrDefault(); loggedUserId = user.uid; } ActivityDetailVIewModel act = new ActivityDetailVIewModel(); if (todo != null) { foreach (var todoItem in todo.listbox) { var temp = todoItem.TItle; var ActivitID = db.Activities.Where(p => p.title.Equals(temp)).Select(p => p.actId).FirstOrDefault(); var actvityList = db.Activities.Find(ActivitID); if (actvityList != null) { actvityList.assignee = loggedUserId; db.SaveChanges(); } } } }
public async Task <IHttpActionResult> Register(UserModel userModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } IdentityResult result = await _repo.RegisterUser(userModel); IHttpActionResult errorResult = GetErrorResult(result); if (errorResult != null) { return(errorResult); } User_TuTU user = new User_TuTU(); user.name = userModel.UserName; user.email = userModel.Email; user.password = userModel.Password; user.companyName = userModel.Company; db.UserTu_Tu.Add(user); db.SaveChanges(); var loginResult = await this.LoginUser(new UserModel() { UserName = userModel.UserName, Password = userModel.Password }); return(loginResult); }
public IHttpActionResult GetUser_TuTU(int id) { User_TuTU user_TuTU = db.UserTu_Tu.Find(id); if (user_TuTU == null) { return(NotFound()); } return(Ok(user_TuTU)); }
public IHttpActionResult PostUser_TuTU(User_TuTU user_TuTU) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.UserTu_Tu.Add(user_TuTU); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = user_TuTU.uid }, user_TuTU)); }
public IHttpActionResult DeleteUser_TuTU(int id) { User_TuTU user_TuTU = db.UserTu_Tu.Find(id); if (user_TuTU == null) { return(NotFound()); } db.UserTu_Tu.Remove(user_TuTU); db.SaveChanges(); return(Ok(user_TuTU)); }
public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) { string clientId = string.Empty; string clientSecret = string.Empty; User_TuTU client = null; if (!context.TryGetBasicCredentials(out clientId, out clientSecret)) { context.TryGetFormCredentials(out clientId, out clientSecret); } if (context.ClientId == null) { //Remove the comments from the below line context.SetError, and invalidate context //if you want to force sending clientId/secrects once obtain access tokens. context.Validated(); //context.SetError("invalid_clientId", "ClientId should be sent."); return(Task.FromResult <object>(null)); } using (AuthRepository _repo = new AuthRepository()) { client = _repo.FindClient(context.ClientId); } if (client == null) { context.SetError("invalid_clientId", string.Format("Client '{0}' is not registered in the system.", context.ClientId)); return(Task.FromResult <object>(null)); } //if (!client.Active) //{ // context.SetError("invalid_clientId", "Client is inactive."); // return Task.FromResult<object>(null); //} //context.OwinContext.Set<string>("as:clientAllowedOrigin", client.AllowedOrigin); //context.OwinContext.Set<string>("as:clientRefreshTokenLifeTime", client.RefreshTokenLifeTime.ToString()); //context.Validated(); return(Task.FromResult <object>(null)); }
/// <summary> /// return todo,progress and done Activities /// </summary> /// <returns></returns> public IEnumerable <ActivityRetrieveViewModel> getActivityList() { List <ActivityRetrieveViewModel> activityViewModelList = new List <ActivityRetrieveViewModel>(); int loggedUserId = 0; if (AccountController.uName != null) { User_TuTU user = db.UserTu_Tu.Where(ac => ac.name.Equals(AccountController.uName)).FirstOrDefault(); loggedUserId = user.uid; } var allItems = db.Activities.ToList().Where(ac => ac.assignee != 0 && ac.assignee == loggedUserId); if (allItems != null) { foreach (var allItem in allItems) { ActivityRetrieveViewModel activityViewModel = new ActivityRetrieveViewModel(); var assignerDetailsByName = db.UserTu_Tu.Find(allItem.assigner); var assigneeDetailsByName = db.UserTu_Tu.Find(allItem.assignee); if (assignerDetailsByName != null) { activityViewModel.assigner = assignerDetailsByName.name; } if (assigneeDetailsByName != null) { activityViewModel.assignee = assigneeDetailsByName.name; } int days = (allItem.expiryDate - DateTime.Today).Days; activityViewModel.title = allItem.title; activityViewModel.description = allItem.description; activityViewModel.expiryDate = allItem.expiryDate.ToString("MM/dd/yyyy"); activityViewModel.completeness = allItem.completeness; activityViewModel.status = allItem.status; activityViewModel.starCount = allItem.starCount; activityViewModel.filePath = allItem.filePath; activityViewModel.remainingDays = days; activityViewModelList.Add(activityViewModel); } } return(activityViewModelList); }
/// <summary> /// Get project counts for different way /// </summary> /// <returns></returns> public IEnumerable <TaskCountViewModel> GetAllTaskCounts() { List <TaskCountViewModel> taskCount = new List <TaskCountViewModel>(); int loggedUserId = 0; if (AccountController.uName != null) { User_TuTU user = db.UserTu_Tu.Where(ac => ac.name.Equals(AccountController.uName)).FirstOrDefault(); loggedUserId = user.uid; } int Completed = db.Activities.Where(ac => ac.status.Equals(const_Done) && ac.assignee == loggedUserId).Count(); int CompletedAndRated = db.Activities.Where(ac => ac.status.Equals(const_Done) && ac.assignee == loggedUserId).Count() + db.Activities.Where(ac => ac.status.Equals(const_Rated) && ac.assignee == loggedUserId).Count(); int NotAssignedOrIsolated = db.Activities.Where(ac => ac.assignee == 0).Count(); int progressProject = db.Activities.Where(ac => ac.status.Equals(const_Todo) && ac.assignee == loggedUserId).Count() + db.Activities.Where(ac => ac.status.Equals(const_Progress) && ac.assignee == loggedUserId).Count(); TaskCountViewModel CompletedTask = new TaskCountViewModel(); CompletedTask.progressTasksCount = Completed; taskCount.Add(CompletedTask); TaskCountViewModel CompletedAndRatedTask = new TaskCountViewModel(); CompletedAndRatedTask.progressTasksCount = CompletedAndRated; taskCount.Add(CompletedAndRatedTask); TaskCountViewModel NotAssignedOrIsolatedTask = new TaskCountViewModel(); NotAssignedOrIsolatedTask.progressTasksCount = NotAssignedOrIsolated; taskCount.Add(NotAssignedOrIsolatedTask); TaskCountViewModel progressProjectTask = new TaskCountViewModel(); progressProjectTask.progressTasksCount = progressProject; taskCount.Add(progressProjectTask); return(taskCount); }