Exemplo n.º 1
0
        public FileResult Logo(Models.Group.GroupRequestModel param)
        {
            try
            {
                GroupBL bl = new GroupBL();

                byte[] logo = bl.GetGroupLogo(param);

                return(this.CreateImageFileResult(logo));
            }
            catch (OrgException oex)
            {
                throw new HttpException((int)System.Net.HttpStatusCode.NotFound, oex.Message);
            }
            catch (Exception ex)
            {
                if (AppConfigs.DebugInternalMessage)
                {
                    throw new HttpException((int)System.Net.HttpStatusCode.InternalServerError, ex.Message);
                }
                else
                {
                    throw new HttpException((int)System.Net.HttpStatusCode.NotFound, AppConfigs.InternalErrorMessage);
                }
            }
        }
Exemplo n.º 2
0
        private GroupBE GetGroupFromUrl()
        {
            GroupBE g;
            string  groupid = DreamContext.Current.GetParam("groupid");

            //Double decoding of name is done to work around a mod_proxy issue that strips out slashes
            groupid = XUri.Decode(groupid);
            if (groupid.StartsWith("="))
            {
                string name = groupid.Substring(1);
                g = GroupBL.GetGroupByName(name);
                if (g == null)
                {
                    throw new GroupNotFoundException(name);
                }
            }
            else
            {
                uint groupIdInt;
                if (!uint.TryParse(groupid, out groupIdInt))
                {
                    throw new GroupIdInvalidArgumentException();
                }
                g = GroupBL.GetGroupById(groupIdInt);
                if (g == null)
                {
                    throw new GroupIdNotFoundException(groupIdInt);
                }
            }
            return(g);
        }
Exemplo n.º 3
0
        public CallContext GroupSave(Group group, CallContext resultContext)
        {
            resultContext.securitySettings = ETEMEnums.SecuritySettings.GroupSave;
            resultContext = new GroupBL().EntitySave <Setting>(group, resultContext);

            return(resultContext);
        }
Exemplo n.º 4
0
 protected GroupBL groupBL(bool isTrue = false)
 {
     if (isTrue)
     {
         return(_groupBLTrue = _groupBLTrue ?? new GroupBL());
     }
     return(_groupBLFalse = _groupBLFalse ?? new GroupBL());
 }
Exemplo n.º 5
0
        // GET: Employee
        public ActionResult Create()
        {
            var id = UserBL.ReadAll().First(u => u.Name == User.Identity.GetUserName()).Id;

            ViewBag.Positions = PositionBL.ReadByCompany(CompanyBL.Read(id).Id);
            ViewBag.Groups    = GroupBL.ReadByCompany(CompanyBL.Read(id).Id);
            return(View(new EmployeeViewModel()));
        }
Exemplo n.º 6
0
        public Yield PostGroupUsers(DreamContext context, DreamMessage request, Result <DreamMessage> response)
        {
            PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
            GroupBE group = GetGroupFromUrl();

            group = GroupBL.AddGroupMembers(group, request.ToDocument());
            response.Return(DreamMessage.Ok(GroupBL.GetGroupXmlVerbose(group, null)));
            yield break;
        }
Exemplo n.º 7
0
        public void AddGroupForTraining(int trainingId, GroupBL groupBL)
        {
            var group = new Group()
            {
                TrainerName = groupBL.TrainerName, ClassNumber = groupBL.ClassNumber, StartTime = groupBL.StartTime
            };

            groupRepozitory.AddGroupForTraining(trainingId, group);
        }
Exemplo n.º 8
0
        public Yield GetGroup(DreamContext context, DreamMessage request, Result <DreamMessage> response)
        {
            PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.READ);
            GroupBE      group       = GetGroupFromUrl();
            DreamMessage responseMsg = DreamMessage.Ok(GroupBL.GetGroupXmlVerbose(group, null));

            response.Return(responseMsg);
            yield break;
        }
Exemplo n.º 9
0
        public Yield DeleteGroupUser(DreamContext context, DreamMessage request, Result <DreamMessage> response)
        {
            PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
            GroupBE group = GetGroupFromUrl();
            UserBE  user  = GetUserFromUrlMustExist();

            group = GroupBL.RemoveGroupMember(group, user);
            response.Return(DreamMessage.Ok(GroupBL.GetGroupXmlVerbose(group, null)));
            yield break;
        }
Exemplo n.º 10
0
        public Yield PostGroup(DreamContext context, DreamMessage request, Result <DreamMessage> response)
        {
            PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
            DreamMessage responseMsg = null;
            GroupBE      group       = GroupBL.PostGroupFromXml(request.ToDocument(), null, context.GetParam("authusername", null), context.GetParam("authpassword", null));

            responseMsg = DreamMessage.Ok(GroupBL.GetGroupXmlVerbose(group, null));
            response.Return(responseMsg);
            yield break;
        }
Exemplo n.º 11
0
        public void AddNewGroup(GroupBL groupBL)
        {
            var group = new Group()
            {
                TrainerName = groupBL.TrainerName,
                ClassNumber = groupBL.ClassNumber,
                StartTime   = groupBL.StartTime
            };

            groupRepozitory.AddNewGroup(group);
        }
Exemplo n.º 12
0
 // GET: GroupController index page. Show all groups and the ones you can join (not already apart of)
 public ActionResult Index()
 {
     try
     {
         return(View(GroupBL.GetGroupsToDisplay(_userManager.GetUserId(User))));
     }
     catch (Exception e)
     {
         TempData["sErrMsg"] = e.Message;
         return(View());
         //return Redirect("~/");
     }
 }
Exemplo n.º 13
0
        public GroupAndFriendResultModel GetContactList()
        {
            GroupAndFriendResultModel result = new GroupAndFriendResultModel();

            try
            {
                int?memberId = IdentityHelper.GetMemberId();
                if (!memberId.HasValue)
                {
                    throw new OrgException("Invalid member MemberId");
                }

                FriendBL friendBl = new FriendBL();

                var favouriteList = friendBl.GetFriends(memberId.Value, true, OrgComm.Data.Models.Friend.StatusType.Active);
                var friendList    = friendBl.GetFriends(memberId.Value, false, OrgComm.Data.Models.Friend.StatusType.Active);

                GroupBL groupBl = new GroupBL();

                var groupList = groupBl.GetGroupsByMember(memberId.Value, null);

                result.Status  = true;
                result.Message = ((friendList.Count + favouriteList.Count == 0) ? "No friend found." : (friendList.Count + favouriteList.Count).ToString() + " friends found. ")
                                 + ((groupList.Count == 0) ? "No group found." : groupList.Count.ToString() + " groups found.");

                result.Favourites = favouriteList;
                result.Friends    = friendList;
                result.Groups     = groupList;
            }
            catch (OrgException oex)
            {
                result.Status  = false;
                result.Message = oex.Message;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = AppConfigs.InternalErrorMessage;

                if (AppConfigs.DebugInternalMessage)
                {
                    result.InternalMessage = ex.Message;
                }
            }

            return(result);
        }
Exemplo n.º 14
0
        // GET: GroupController/join
        public ActionResult Join(int id)
        {
            try
            {
                if (id == 0)
                {
                    return(NotFound());
                }
                var group = GroupBL.GetGroup(id);

                return(View(group));
            }
            catch
            {
                return(Redirect("~/"));
            }
        }
Exemplo n.º 15
0
        public List <GroupBL> GetGroupsByTrainingId(int id)
        {
            var listBL = new List <GroupBL>();
            var list   = groupRepozitory.GetGroupsByTrainingId(id);

            foreach (var gr in list)
            {
                var groupBL = new GroupBL()
                {
                    ID             = gr.ID,
                    TrainerName    = gr.TrainerName,
                    StartTime      = gr.StartTime,
                    TrainingKindId = gr.TrainingKindId,
                    Training       = gr.Training
                };
                listBL.Add(groupBL);
            }
            return(listBL);
        }
Exemplo n.º 16
0
        public ActionResult Create(GroupViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var id = UserBL.ReadAll().First(u => u.Name == User.Identity.GetUserName()).Id;
                    viewModel.CompanyId = CompanyBL.Read(id).Id;

                    GroupBL.Create(viewModel);
                    return(RedirectToAction("../Company/Company"));
                }
                return(View(new GroupViewModel()));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 17
0
 public ActionResult Edit(GroupViewModel viewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             GroupBL.Update(viewModel);
             return(RedirectToAction("../Company/Company"));
         }
         else
         {
             throw new Exception();
         }
     }
     catch
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
         throw;
     }
 }
Exemplo n.º 18
0
        public Yield GetGroups(DreamContext context, DreamMessage request, Result <DreamMessage> response)
        {
            PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.READ);
            uint            totalCount, queryCount;
            IList <GroupBE> groups = GroupBL.GetGroupsByQuery(context, out totalCount, out queryCount);

            XDoc result = new XDoc("groups");

            result.Attr("count", groups.Count);
            result.Attr("querycount", queryCount);
            result.Attr("totalcount", totalCount);
            result.Attr("href", DekiContext.Current.ApiUri.At("groups"));

            foreach (GroupBE g in groups)
            {
                result.Add(GroupBL.GetGroupXmlVerbose(g, null));
            }

            response.Return(DreamMessage.Ok(result));
            yield break;
        }
Exemplo n.º 19
0
        public GroupResultModel CreateGroup(CreateGroupRequestModel param)
        {
            GroupResultModel result = new GroupResultModel();

            try
            {
                int?memberId = IdentityHelper.GetMemberId();
                if (!memberId.HasValue)
                {
                    throw new OrgException("Invalid MemberId");
                }

                GroupBL bl = new GroupBL();

                var group = bl.CreateGroup(memberId.Value, param, OrgComm.Data.Models.Group.GroupType.Other);

                result.Status  = true;
                result.Message = "Group created";
                result.Group   = group;
            }
            catch (OrgException oex)
            {
                result.Status  = false;
                result.Message = oex.Message;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = AppConfigs.InternalErrorMessage;

                if (AppConfigs.DebugInternalMessage)
                {
                    result.InternalMessage = ex.Message;
                }
            }

            return(result);
        }
Exemplo n.º 20
0
 public JsonResult AutoComplete(string prefix)
 {
     try
     {
         List <UserInfo>  usrList = (List <UserInfo>)UserBL.GetUsers();
         List <GroupInfo> grpList = (List <GroupInfo>)GroupBL.GetGroups();
         prefix = prefix.ToLower();
         var reciverUsrList = (from N in usrList
                               where N.Email.ToLower().StartsWith(prefix)
                               select new { Recipient = N.Email });
         var reciverGrpList = (from N in grpList
                               where N.Name.ToLower().StartsWith(prefix)
                               select new { Recipient = N.Name });
         var reciverList = reciverUsrList.Concat(reciverGrpList);
         return(Json(reciverList));
     }
     catch (Exception e)
     {
         TempData["sErrMsg"] = e.Message;
         return(Json("Something unintended happend, try again."));
         //return Redirect("~/");
     }
 }
Exemplo n.º 21
0
        public ActionResult Create([Bind("Name")] GroupInfo group)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    GroupBL.AddGroup(group);

                    //Display confirmation that a group was created and when
                    TempData["custdetails"] = string.Format("The group  \"{0}\"was created, {1}", group.Name, DateTime.Now.ToString("HH:mm MM/dd/yyyy"));
                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 22
0
        public ResultModel LeaveGroup(LeaveGroupRequestModel param)
        {
            ResultModel result = new ResultModel();

            try
            {
                int?memberId = IdentityHelper.GetMemberId();
                if (!memberId.HasValue)
                {
                    throw new OrgException("Invalid MemberId");
                }

                GroupBL bl = new GroupBL();

                bl.Leave(memberId.Value, param);

                result.Status  = true;
                result.Message = "Leave group successfully";
            }
            catch (OrgException oex)
            {
                result.Status  = false;
                result.Message = oex.Message;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = AppConfigs.InternalErrorMessage;

                if (AppConfigs.DebugInternalMessage)
                {
                    result.InternalMessage = ex.Message;
                }
            }

            return(result);
        }
 public List <Group> GetMyGroups(string userId)
 {
     return(GroupBL.GetMyGroups(userId));
 }
Exemplo n.º 24
0
        //
        // GET: /Group/Edit/5
        public ActionResult Edit(int id)
        {
            var _model = (GroupViewModel)GroupBL.Read(id);

            return(View(_model));
        }
 public Group AddGroup([FromBody] Group group)
 {
     return(GroupBL.AddGroup(group));
 }
 public Group GetGroupById(string groupId)
 {
     return(GroupBL.GetGroupByID(groupId));
 }
 public void UpdateGroup([FromBody] Group group)
 {
     GroupBL.UpdateGroup(group);
 }
 public void UpdateParticipents(string newParticpents, string objectId)
 {
     GroupBL.UpdateGroupParticipents("Participents", JsonConvert.DeserializeObject <List <string> >(newParticpents), objectId);
 }