public ActionResult ExporttoExcel()
        {
            var customerdata = ManageCustomerService.ManageEvents(0, Convert.ToString(TempData["SearchTitle"]));
            List <ManageEventModel> ManageEventModel = new List <Models.ManageEventModel>();

            foreach (var item in customerdata)
            {
                var model = new ManageEventModel();
                model.CustomerName   = item.Name;
                model.EventName      = item.EventName;
                model.EventStartDate = item.EventStartDate;
                model.EventEndDate   = item.EventEndDate;
                model.RegisteredUser = item.TotalCount;
                model.ReferredUser   = item.ReferredUsers;
                ManageEventModel.Add(model);
            }

            GridView gv = new GridView();

            gv.DataSource = ManageEventModel;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=ManageEvent.xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset     = "";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Handles GET requests for the Event View </summary>
        /// <remarks>   Andre Beging, 27.04.2018. </remarks>
        /// <param name="id">   The identifier. </param>
        /// <returns>   An IActionResult. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public IActionResult Event(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(RedirectToAction("Events"));
            }

            var model = new ManageEventModel();

            using (var context = ContextHelper.OpenContext())
            {
                var contextEvent = context.Event
                                   .Include(e => e.EventUsers)
                                   .FirstOrDefault(e => e.EventId == id);

                if (contextEvent == null)
                {
                    return(RedirectToAction("Events"));
                }

                model.EventId     = contextEvent.EventId;
                model.Start       = contextEvent.Start;
                model.End         = contextEvent.End;
                model.Name        = contextEvent.Name;
                model.Description = contextEvent.Description;
                model.Code        = contextEvent.Code;
                model.Type        = contextEvent.Type;
                model.Status      = contextEvent.Status;
                model.UserCount   = contextEvent.EventUsers.Count;
                model.EventOwner  = contextEvent.OwnerId;
                model.UserList    = context.User.ToDictionary(x => x.UserId, x => string.Format("{0} ({1})", x.Username, x.Mail));

                return(View(model));
            }
        }
 public ActionResult Index(ManageEventModel model)
 {
     if (Session["CustomerId"] == null)
     {
         return(RedirectToAction("Login", "Home"));
     }
     return(View(model));
 }
Ejemplo n.º 4
0
        public int Add(ManageEventModel model)
        {
            using (var scope = new TransactionScope())
            {
                try
                {
                    model.Image = Cdn.Base64ToImageUrl(model.Image);
                    var eventId = _event.Add(new EventModel()
                    {
                        Image        = model.Image,
                        Title        = model.Title,
                        Message      = model.Message,
                        CreatedBy    = model.UserId,
                        DateTime     = model.DateTime,
                        EntityId     = model.EntityId,
                        EntityTypeId = model.EntityTypeId,
                        OccationId   = model.OccationId
                    });

                    // Adding Users
                    foreach (var user in model.Users)
                    {
                        _eventUser.Add(new EventUserModel()
                        {
                            UserId    = user.UserId,
                            CreatedBy = model.UserId,
                            EventId   = eventId
                        });
                    }

                    // Adding Groups
                    foreach (var group in model.Groups)
                    {
                        _eventGroup.Add(new EventGroupModel()
                        {
                            GroupId   = group,
                            CreatedBy = model.UserId,
                            EventId   = eventId
                        });
                    }

                    scope.Complete();

                    return(eventId);
                }
                catch (Exception ex)
                {
                    scope.Dispose();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string json             = js.Serialize(model);
                    Log.Error("BL-Group - Add" + json, ex);
                    throw new ReturnExceptionModel(new CustomExceptionModel()
                    {
                        StatusCode = HttpStatusCode.BadRequest, Message = ex.Message
                    });
                }
            }
        }
Ejemplo n.º 5
0
        public IActionResult Edit(int eventId)
        {
            var model = new ManageEventModel
            {
                Event = _context.Events.Single(x => x.Id == eventId),
            };

            return(View(model));
        }
Ejemplo n.º 6
0
        public IActionResult Create()
        {
            var model = new ManageEventModel
            {
                Event = new Event()
            };

            return(View("Edit", model));
        }
Ejemplo n.º 7
0
        public ActionResult ManageEvents(string userObjectId, string eventId, string clientTimeZone)
        {
            this.ViewBag.EmptyView      = true;
            this.ViewBag.userObjectId   = userObjectId;
            this.ViewBag.eventId        = eventId;
            this.ViewBag.clientTimeZone = clientTimeZone;

            ManageEventModel manageEventModel = new ManageEventModel()
            {
                TeamDetails  = new List <Team>(),
                TimeZoneList = new List <TimeZoneDisplayInfo>(),
            };

            return(this.View(manageEventModel));
        }
Ejemplo n.º 8
0
        public IActionResult Event(ManageEventModel model)
        {
            if (model == null)
            {
                return(RedirectToAction("Events"));
            }
            if (model.EventId == Guid.Empty)
            {
                return(RedirectToAction("Events"));
            }
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Event", new { id = model.EventId }));
            }

            using (var context = ContextHelper.OpenContext())
            {
                var contextEvent = context.Event.FirstOrDefault(e => e.EventId == model.EventId);

                if (contextEvent != null)
                {
                    if (!string.IsNullOrWhiteSpace(model.Name))
                    {
                        contextEvent.Name = model.Name;
                    }

                    if (model.EventOwner != Guid.Empty)
                    {
                        contextEvent.OwnerId = model.EventOwner;
                    }

                    contextEvent.Description = model.Description;
                    contextEvent.Start       = model.Start;
                    contextEvent.End         = model.End;
                    contextEvent.Type        = model.Type;


                    context.SaveChanges();
                }
            }

            return(RedirectToAction("Event", new { id = model.EventId }));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> ManageEventData(string userObjectId, string eventId, string clientTimeZone)
        {
            this.ViewBag.EmptyView = false;
            string windowsTimeZoneId;

            TZConvert.TryIanaToWindows(clientTimeZone, out windowsTimeZoneId);
            ManageEventModel manageEventModel = new ManageEventModel()
            {
                TeamDetails        = await this.GetTeamDetailsWhereBothBotAndUsersAreInAsync(userObjectId),
                TimeZoneList       = Common.GetTimeZoneList(),
                SelectedTimeZoneId = windowsTimeZoneId,
            };

            if (!string.IsNullOrWhiteSpace(eventId))
            {
                manageEventModel.CelebrationEvent = await this.eventHelper.GetEventByEventIdAsync(eventId, userObjectId);
            }

            return(this.PartialView("ManageEvents", manageEventModel));
        }
        private IEnumerable GetData(int SearchRecords, string SearchTitle, string Alpha)
        {
            SearchTitle = SearchTitle.Trim().ToLower();
            Alpha       = Alpha.Trim().ToLower();
            List <ManageEventModel> Customerlist = new List <ManageEventModel>();
            var customerdata = ManageCustomerService.ManageEvents(0, SearchTitle);

            foreach (var data in customerdata)
            {
                ManageEventModel model = new ManageEventModel();
                model.CustomerName   = data.Name;
                model.EventName      = data.EventName;
                model.EventStartDate = data.EventStartDate;
                model.EventEndDate   = data.EventEndDate;
                model.RegisteredUser = data.TotalCount;
                model.ReferredUser   = data.ReferredUsers;
                Customerlist.Add(model);
            }

            return(Customerlist);
        }
Ejemplo n.º 11
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   User event. </summary>
        ///
        /// <remarks>   Andre Beging, 25.05.2018. </remarks>
        ///
        /// <param name="id">   The identifier. </param>
        ///
        /// <returns>   An IActionResult. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public IActionResult UserEvent(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(RedirectToAction("UserEvents"));
            }

            var user = HttpContext.GetUser();

            if (user == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            var model = new ManageEventModel();

            using (var context = ContextHelper.OpenContext())
            {
                var contextEvent = context.Event
                                   .Include(e => e.EventUsers)
                                   .FirstOrDefault(e => e.EventId == id && e.OwnerId == user.UserId && e.Type != EventType.Public);

                if (contextEvent == null)
                {
                    return(RedirectToAction("UserEvents"));
                }

                model.EventId     = contextEvent.EventId;
                model.Start       = contextEvent.Start;
                model.End         = contextEvent.End;
                model.Name        = contextEvent.Name;
                model.Description = contextEvent.Description;
                model.Code        = contextEvent.Code;
                model.Status      = contextEvent.Status;
                model.UserCount   = contextEvent.EventUsers.Count;

                return(View(model));
            }
        }
Ejemplo n.º 12
0
 public bool Edit(ManageEventModel model)
 {
     return(_event.Edit(model));
 }
Ejemplo n.º 13
0
 public int Add(ManageEventModel model)
 {
     return(_event.Add(model));
 }
Ejemplo n.º 14
0
        public bool Edit(ManageEventModel model)
        {
            using (var scope = new TransactionScope())
            {
                try
                {
                    model.Image = Cdn.Base64ToImageUrl(model.Image);
                    var groupId = _event.Edit(new EventModel()
                    {
                        Image        = model.Image,
                        Title        = model.Title,
                        Message      = model.Message,
                        CreatedBy    = model.UserId,
                        DateTime     = model.DateTime,
                        EntityId     = model.EntityId,
                        EntityTypeId = model.EntityTypeId,
                        OccationId   = model.OccationId
                    });

                    #region User management

                    var existedUsers = _eventUser.GetAllUsers(model.EventId);
                    var newUsers     = model.Users.Select(x => x.UserId).ToList();
                    foreach (var user in model.Users)
                    {
                        if (!existedUsers.Contains(user.UserId))
                        {
                            _eventUser.Add(new EventUserModel()
                            {
                                UserId    = user.UserId,
                                CreatedBy = model.UserId,
                            });
                        }
                        else
                        {
                            _eventUser.UpdateRole(new UpdateRoleModel()
                            {
                                UserId  = user.UserId,
                                GroupId = model.EventId,
                                RoleId  = user.RoleId
                            });
                        }
                    }

                    foreach (var item in existedUsers)
                    {
                        if (!newUsers.Contains(item))
                        {
                            _eventUser.Delete(model.EventId, item);
                        }
                    }

                    #endregion

                    #region Group Management

                    var existedGroups = _eventGroup.GetGroupIds(model.EventId);

                    foreach (var group in model.Groups)
                    {
                        if (!existedGroups.Contains(group))
                        {
                            _eventGroup.Add(new EventGroupModel()
                            {
                                EventId   = model.EventId,
                                GroupId   = group,
                                CreatedBy = model.UserId,
                            });
                        }
                    }

                    foreach (var item in existedGroups)
                    {
                        if (!model.Groups.Contains(item))
                        {
                            _eventGroup.Delete(model.EventId, item);
                        }
                    }

                    #endregion


                    scope.Complete();

                    return(groupId);
                }
                catch (Exception ex)
                {
                    scope.Dispose();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string json             = js.Serialize(model);
                    Log.Error("BL-Group - Edit" + json, ex);
                    throw new ReturnExceptionModel(new CustomExceptionModel()
                    {
                        StatusCode = HttpStatusCode.BadRequest, Message = ex.Message
                    });
                }
            }
        }