Example #1
0
 public ActionResult Edit([Bind(Include = "Id,Name,IsActive")] Location location)
 {
     if (ModelState.IsValid)
     {
         db.Entry(location).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(location));
 }
Example #2
0
        public ActionResult Edit([Bind(Include = "ContactId,FirstName,LastName,Email,PhoneNumber,SchedulerUserId")] Contact contact)
        {
            if (!ModelState.IsValid)
            {
                return(View(contact));
            }

            contact.SchedulerUserId  = GetCurrentUserId();
            _db.Entry(contact).State = EntityState.Modified;
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
        public ActionResult Edit([Bind(Include = "JobId,CollectionId,Type,Name,AppKey,Process,Description,CronExpression,JobUrl,ProcessResult,SendSummary,Created,Updated,Status")] EditJobViewModel jobViewModel)
        {
            try
            {
                using (var ctx = new SchedulerDbContext())
                {
                    // Get existing job from db
                    var job = ctx.Jobs.Where(j => j.JobId == jobViewModel.JobId).FirstOrDefault();

                    job.Type           = jobViewModel.Type;
                    job.Name           = jobViewModel.Name;
                    job.CronExpression = jobViewModel.CronExpression;
                    job.AppKey         = jobViewModel.AppKey;
                    job.Process        = jobViewModel.Process;
                    job.Description    = jobViewModel.Description;
                    job.JobUrl         = jobViewModel.JobUrl;
                    job.Status         = jobViewModel.Status;

                    //Get tenantId
                    var tenantID = ctx.Collections.Where(t => t.CollectionId == jobViewModel.CollectionId).FirstOrDefault().TenantId;

                    if (User.IsInRole("SystemAdministrator") || tenantID == CurrentTenant.TenantId)
                    {
                        if (ModelState.IsValid)
                        {
                            ctx.Entry(job).State = EntityState.Modified;
                            ctx.SaveChanges();
                            return(RedirectToAction("Index"));
                        }
                        ViewBag.CollectionId = new SelectList(ctx.Collections.ToList(), "CollectionId", "Name", job.CollectionId);
                    }
                    else
                    {
                        return(View("Authorize"));
                    }
                }
            }

            catch (Exception ex)
            {
                LogService.Info("Jobs not found", ex.Message, ex.InnerException);
            }


            return(View(jobViewModel));
        }
        public ActionResult Edit([Bind(Include = "CollectionId,ApplicationId,TenantId,Name,Created,Status")] EditJobCollectionViewModel collectionViewModel)
        {
            try
            {
                if (User.IsInRole("SystemAdministrator") || collectionViewModel.TenantId == CurrentTenant.TenantId)
                {
                    using (var ctx = new SchedulerDbContext())
                    {
                        // Get existing collection from db
                        var collection = ctx.Collections.Where(c => c.CollectionId == collectionViewModel.CollectionId).FirstOrDefault();

                        collection.Name   = collectionViewModel.Name;
                        collection.Status = collectionViewModel.Status;

                        if (ModelState.IsValid)
                        {
                            //Update collection
                            ctx.Entry(collection).State = EntityState.Modified;
                            ctx.SaveChanges();
                            return(RedirectToAction("Index"));
                        }
                    }
                }
                else
                {
                    return(View("Authorize"));
                }

                using (var saaSctx = new SaasDbContext())
                {
                    ViewBag.TenantId      = new SelectList(saaSctx.Tenants.ToList(), "TenantId", "Name");
                    ViewBag.ApplicationId = new SelectList(saaSctx.Applications.ToList(), "Id", "Name");
                }
            }

            catch (Exception ex)
            {
                LogService.Info("Collections not found", ex.Message, ex.InnerException);
            }

            return(View(collectionViewModel));
        }
Example #5
0
 public void AssignmentSaveChanges(Assignment assignment)
 {
     db.Entry(assignment).State = EntityState.Modified;
     db.SaveChanges();
 }
Example #6
0
        public ActionResult Edit([Bind(Include = "Id,Title,Location,Description,StartDate,EndDate,ReminderDate,ListDate,SchedulerUserId")]
                                 Event eventToEdit, int?id)
        {
            var results = eventToEdit.StartDate.GetValueOrDefault().CompareTo(eventToEdit.ListDate.GetValueOrDefault());

            if (results < 0)
            {
                ModelState.AddModelError("dateError", "Enter date before Starting date");
            }

            if (!ModelState.IsValid)
            {
                return(View(eventToEdit));
            }

            _db.Entry(eventToEdit).State = EntityState.Modified;
            _db.SaveChanges();

            var remanderDate = Service.GetRemanderDate(eventToEdit);
            var listDate     = Service.GetListDate(eventToEdit);

            //Remove scheduled jobs of this event
            JobManager.RemoveScheduledJobs(eventToEdit);

            #region Send update emails to participants
            //Get Participants
            var currentEvent = _db.Events
                               .Where(e => e.Id == eventToEdit.Id)
                               .Include(e => e.Participants)
                               .FirstOrDefault();

            if (currentEvent == null)
            {
                return(View("Error"));
            }

            var participants = currentEvent.Participants.ToList();

            var user = _service.GetUser();

            EmailInformation emailInfo = null;
            var emails = new List <EmailInformation>();

            //There is no participants
            if (participants.Count == 0)
            {
                return(RedirectToAction("Index"));
            }

            foreach (var participant in participants)
            {
                var participantId = participant.Id;
                var detailsUrl    = Url.Action("Details", "Response",
                                               new RouteValueDictionary(new { id = currentEvent.Id }), "https");
                var responseUrl = Url.Action("Response", "Response",
                                             new RouteValueDictionary(new { id = currentEvent.Id, pId = participantId }), "https");

                emailInfo = new EmailInformation
                {
                    CurrentEvent     = currentEvent,
                    OrganizerName    = user.FirstName,
                    OrganizerEmail   = user.UserName,
                    ParticipantId    = participantId,
                    ParticipantEmail = participant.Email,
                    EmailSubject     = " changes.",
                    ResponseUrl      = responseUrl,
                    EventDetailsUrl  = detailsUrl
                };

                emails.Add(emailInfo);

                //Notify Participant using postal
                PostalEmailManager.SendEmail(emailInfo, new EmailInfoChangeEmail());
            }
            #endregion


            //Schedule remainders only when there is a remainder date
            if (eventToEdit.ReminderDate != null)
            {
                JobManager.ScheduleRemainderEmail(emails, remanderDate);
            }
            //Schedule new emails for edited Job
            JobManager.ScheduleParticipantListEmail(emailInfo, listDate);
            //JobManager.AddJobsIntoEvent(eventToEdit.Id,"Send List");

            return(RedirectToAction("Index"));
        }
Example #7
0
 public async Task Update(T entity)
 {
     context.Entry(entity).State = EntityState.Modified;
     await context.SaveChangesAsync();
 }