public async Task <IHttpActionResult> searchbyself(DAL.Goal model) { System.Web.HttpContext.Current.Application.Lock(); var userId = User.Identity.GetUserId(); var Goal = from gh in _db.GoalHandlers join g in _db.Goals on gh.goalID equals g.id join c in _db.Circles on g.circleID equals c.id where gh.userID.Equals(userId) select new { id = g.id, goalName = g.goalName, description = g.description, categoryID = g.categoryID, circleID = g.circleID, userName = g.User.firstname, userLastName = g.User.lastname, startDate = g.startDate, endDate = g.endDate, categoryName = g.Category.categoryName, circleName = g.Circle.circleName, // circleTime = g.Circle.circleTime circleType = g.circleType, userID = g.userID, me = userId, startDate2 = g.Circle.startDate, endDate2 = g.Circle.endDate }; if (model.goalName != null) { Goal = from m in Goal where m.goalName.Contains(model.goalName) select m; } if (model.categoryID != 0) { Goal = from m in Goal where m.categoryID == model.categoryID select m; } if (model.circleType != 0) { Goal = from m in Goal where m.circleType == model.circleType select m; } Goal = from m in Goal orderby m.goalName select m; System.Web.HttpContext.Current.Application.UnLock(); return(Json(Goal)); }
public async Task <IHttpActionResult> isDuplicateNameUpdate(DAL.Goal model) { Boolean result = false; System.Web.HttpContext.Current.Application.Lock(); var goal = _db.Goals.Where(p => p.goalName == model.goalName).FirstOrDefault(); if (goal == null || goal.goalName == model.goalName) { result = true; } System.Web.HttpContext.Current.Application.UnLock(); return(Json(new { result = result })); }
public async Task <IHttpActionResult> searchbyCommanderCourse(DAL.Goal model) { var userId = User.Identity.GetUserId(); var Goal = from g in _db.Goals join c in _db.Circles on g.circleID equals c.id where g.userID.Equals(userId) && g.flag == 3 select new { id = g.id, goalName = g.goalName, description = g.description, userName = g.User.firstname, userLastName = g.User.lastname, startDate = g.startDate, endDate = g.endDate, circleID = g.circleID, circleName = g.Circle.circleName, circleType = g.circleType, categoryID = g.categoryID, categoryName = g.Category.categoryName, startDate2 = g.Circle.startDate, endDate2 = g.Circle.endDate }; if (model.goalName != null) { Goal = from m in Goal where m.goalName.Contains(model.goalName) select m; } if (model.categoryID != 0) { Goal = from m in Goal where m.categoryID == model.categoryID select m; } if (model.circleType != 0) { Goal = from m in Goal where m.circleType == model.circleType select m; } Goal = from m in Goal orderby m.goalName select m; return(Json(Goal)); }