//api/ActionParameter/Get? public string Get(string authcode, string actionType, string action) { if (authcode == null || actionType == null || action == null) { return("There is an error with the request send. Please contact our support."); } actionType = actionType.Replace("_", " ").ToLower(); var user = db.AspNetUsers.Find(authcode); if (user == null) { return("This website isn't registered in our service or it's account has been suspended."); } UserToAction uta = db.UserToAction.Where(u => u.UserId == authcode).Where(x => x.PlanToActions.ActionType1.ActionType1.ToLower() == actionType).Where(m => m.PlanToActions.Actions.ActionParameter == action).FirstOrDefault(); if (uta != null) { string result = uta.BaseURLVariable + "/" + uta.ParameterVariable; return(result); } else { return("Parameter not found"); } }
// GET: Actions/Delete/5 public async Task <ActionResult> Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserToAction uta = await db.UserToAction.FindAsync(id); if (uta == null) { return(HttpNotFound()); } db.UserToAction.Remove(uta); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> AddNewActions(long checkedId) { if (!ModelState.IsValid) { return(Json("")); } var userId = User.Identity.GetUserId(); var utaExisting = db.UserToAction.Where(x => x.PlanToActions.Actions.ActionId == checkedId).FirstOrDefault(); if (utaExisting != null) { db.UserToAction.Remove(utaExisting); } else { UserToAction uta = new UserToAction(); uta.UserId = userId; var geTask = await db.GeneralInfo.Where(x => x.AspNetUsers.Id == userId).FirstOrDefaultAsync(); uta.BaseURLVariable = geTask.Website; uta.PlanToActions = await db.PlanToActions.Where(x => x.ActionParameter == checkedId).FirstOrDefaultAsync(); if (uta.PlanToActions != null) { db.UserToAction.Add(uta); } } await db.SaveChangesAsync(); var userActionEntries = db.UserToAction.Where(x => x.UserId == userId); List <PlanToActions> availableActionEntries = await db.PlanToActions.Where(x => x.SiteType == 1).ToListAsync(); List <string> siteThemesList = new List <string>(); foreach (UserToAction uta in userActionEntries) { if (!siteThemesList.Contains(uta.PlanToActions.SiteTheme1.SiteTheme1)) { siteThemesList.Add(uta.PlanToActions.SiteTheme1.SiteTheme1); } } ViewBag.siteThemesList = siteThemesList; return(PartialView("~/Views/Shared/Actions/_ActionsPage.cshtml", await userActionEntries.ToListAsync())); }