public ActionResult DeleteGroup(long id) { var gVal = new GenericValidator(); try { if (id < 1) { gVal.Code = -1; gVal.Error = "Invalid selection"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var delStatus = new GroupServices().DeleteGroup(id); if (delStatus < 1) { gVal.Code = -1; gVal.Error = "Group could not be deleted. Please try again later."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = 5; gVal.Error = "Group Information was successfully deleted"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public GroupsPartialController(IMessageServices messageServices, IRoleServices roleServices, IUserServices userServices, SchoolServices schoolServices, GroupServices groupServices) :base(userServices, messageServices, roleServices) { this.schoolServices = schoolServices; this.groupServices = groupServices; }
public EffectiveMunkiTemplate() { _munkiManifestTemplateServices = new MunkiManifestTemplateServices(); _groupServices = new GroupServices(); _groupMunkiServices = new GroupMunkiServices(); _computerServices = new ComputerServices(); _computerMunkiServices = new ComputerMunkiServices(); }
public ActionResult EditGroup(GroupObject group) { var gVal = new GenericValidator(); try { //if (!ModelState.IsValid) //{ // gVal.Code = -1; // gVal.Error = "Plese provide all required fields and try again."; // return Json(gVal, JsonRequestBehavior.AllowGet); //} if (string.IsNullOrEmpty(group.Name.Trim())) { gVal.Code = -1; gVal.Error = "Please provide Group."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_group"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldgroup = Session["_group"] as GroupObject; if (oldgroup == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldgroup.Name = group.Name.Trim(); var docStatus = new GroupServices().UpdateGroup(oldgroup); if (docStatus < 1) { gVal.Code = -1; gVal.Error = "Group information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldgroup.Id; gVal.Error = "Group information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "Group information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
private void CreateGroup() { using (var groupService = new GroupServices()) { var group = groupService.Create(securityToken, "GroupTest"); idGroup = group; Assert.IsTrue(idGroup > 0); } }
public ActionResult GetGroupObjects(JQueryDataTableParamModel param) { try { IEnumerable <GroupObject> filteredParentMenuObjects; var countG = 0; var pagedParentMenuObjects = GetGroups(param.iDisplayLength, param.iDisplayStart, out countG); if (!string.IsNullOrEmpty(param.sSearch)) { filteredParentMenuObjects = new GroupServices().Search(param.sSearch); } else { filteredParentMenuObjects = pagedParentMenuObjects; } if (!filteredParentMenuObjects.Any()) { return(Json(new List <GroupObject>(), JsonRequestBehavior.AllowGet)); } //var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func <GroupObject, string> orderingFunction = (c => c.Name); var sortDirection = Request["sSortDir_0"]; // asc or desc filteredParentMenuObjects = sortDirection == "desc" ? filteredParentMenuObjects.OrderBy(orderingFunction) : filteredParentMenuObjects.OrderByDescending(orderingFunction); var displayedPersonnels = filteredParentMenuObjects; var result = from c in displayedPersonnels select new[] { Convert.ToString(c.Id), c.Name }; return(Json(new { param.sEcho, iTotalRecords = countG, iTotalDisplayRecords = countG, aaData = result }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(Json(new List <GroupObject>(), JsonRequestBehavior.AllowGet)); } }
public ActionResult AddGroup(GroupObject group) { var gVal = new GenericValidator(); try { //if (!ModelState.IsValid) //{ // gVal.Code = -1; // gVal.Error = "Plese provide all required fields and try again."; // return Json(gVal, JsonRequestBehavior.AllowGet); //} var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateGroup(group); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new GroupServices().AddGroup(group); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "Group upload failed. Please try again." : "The Group Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Group was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Group processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public It3Tests() { using (var userService = new UserServices()) using (var groupService = new GroupServices()) { securityToken = userService.Register(new UserRegistrationDto { FirstName = "Integration", LastName = "1", Username = username, Password = password, ConfirmPassword = password }); var group = groupService.Create(securityToken, "GroupTest"); idGroup = group; } }
public async Task <bool> Process(ITelegramBotClient botClient, Update update, NeededItems n) { if (n.Sender.Id == botClient.BotId) { await botClient.SendTextMessageAsync(n.ChatId, $"HI there ..."); var c = new GroupServices(); if (!await c.CheckByTlId(n.ChatId)) { await c.Create(new Models.BaseModels.Group { About = "", OwnerId = 0, TelegramId = n.ChatId, Title = update.Message.Chat.Title, WelcomeMessage = "" }); } } else { if (n.Sender.IsBot) { return(true); } var c = new GroupServices(); if (await c.CheckByTlId(n.ChatId)) { var wlc = await c.WlcmsgByTlId(n.ChatId).ConfigureAwait(false); if (string.IsNullOrEmpty(wlc)) { wlc = "Hi there {namelink}"; } wlc = ParseWelcome(wlc, update.Message.Chat, n.Sender); await botClient.SendTextMessageAsync(n.ChatId, wlc, ParseMode.Html); } } return(true); }
public ActionResult GetGroup(long id) { try { var group = new GroupServices().GetGroup(id); if (group == null || group.Id < 1) { return(Json(new GroupObject(), JsonRequestBehavior.AllowGet)); } Session["_group"] = group; return(Json(group, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new GroupObject(), JsonRequestBehavior.AllowGet)); } }
public GroupController() { this.service = new GroupServices(); }
public GroupController() { _groupServices = new GroupServices(); _userId = Convert.ToInt32(((ClaimsIdentity)User.Identity).Claims.Where(c => c.Type == "user_id") .Select(c => c.Value).SingleOrDefault()); }
public GroupController(GroupServices groupServices) { this.groupServices = groupServices; }
public GroupController() { services = new GroupServices(); }
public int Run() { //Find the best multicast server to use var serverId = -1; if (SettingServices.ServerIsNotClustered) { return(serverId); } var clusterServices = new ClusterGroupServices(); ClusterGroupEntity clusterGroup; if (_group != null) { clusterGroup = new GroupServices().GetClusterGroup(_group.Id); } else { //on demand group might be null //use default cluster group if (_clusterId == -1) { clusterGroup = clusterServices.GetDefaultClusterGroup(); } else { clusterGroup = new ClusterGroupServices().GetClusterGroup(_clusterId); } } var availableMulticastServers = new ClusterGroupServices().GetClusterMulticastServers(clusterGroup.Id); if (!availableMulticastServers.Any()) { return(-2); } var taskInUseDict = new Dictionary <int, int>(); foreach (var mServer in availableMulticastServers) { var counter = new ActiveMulticastSessionServices().GetAll() .Count(x => x.ServerId == mServer.ServerId); taskInUseDict.Add(mServer.ServerId, counter); } if (taskInUseDict.Count == 1) { serverId = taskInUseDict.Keys.First(); } else if (taskInUseDict.Count > 1) { var orderedInUse = taskInUseDict.OrderBy(x => x.Value); if (taskInUseDict.Values.Distinct().Count() == 1) { //all multicast server have equal tasks - randomly choose one. var index = _random.Next(0, taskInUseDict.Count); serverId = taskInUseDict[index]; } else { //Just grab the first one with the smallest queue, could be a duplicate but will eventually even out on it's own serverId = orderedInUse.First().Key; } } return(serverId); }
public async Task <bool> Process(ITelegramBotClient botClient, Update update, NeededItems n) { ChatMember[] admins = await botClient.GetChatAdministratorsAsync(n.ChatId); if (admins.Any(x => x.User.Id == n.Sender.Id)) { GroupServices c = new GroupServices(); switch (n.Params[0]) { case "/setwelcome": { if (string.IsNullOrEmpty(update.Message.ReplyToMessage.Text)) { return(true); } Models.BaseModels.Group chat = await c.GetByTlId(n.ChatId); await c.UpdateWelcome(n.ChatId, update.Message.ReplyToMessage.Text); try { await botClient.SendTextMessageAsync(n.ChatId, update.Message.ReplyToMessage.Text, ParseMode.Html); } catch (Exception ex) { await botClient.SendTextMessageAsync(n.ChatId, ex.Message, ParseMode.Html); } await botClient.SendTextMessageAsync(n.ChatId, "Done!"); return(true); } case "/setabout": { if (string.IsNullOrEmpty(update.Message.ReplyToMessage.Text)) { return(true); } Models.BaseModels.Group chat = await c.GetByTlId(n.ChatId); await c.UpdateAbout(n.ChatId, update.Message.ReplyToMessage.Text); try { await botClient.SendTextMessageAsync(n.ChatId, update.Message.ReplyToMessage.Text, ParseMode.Html); } catch (Exception ex) { await botClient.SendTextMessageAsync(n.ChatId, ex.Message, ParseMode.Html); } await botClient.SendTextMessageAsync(n.ChatId, "Done!"); return(true); } default: break; } } else { await botClient.SendTextMessageAsync(n.ChatId, "Admin only"); } return(true); }