public ActionResult EditActivityModel(CampaignActivityEditModel model) { if (ModelState.IsValid) { var camapign = _campaignService.GetEditModel(model.CampaigndId); var campaignActivities = camapign.CampaignActivity.IsNullOrEmpty() ? new List <CampaignActivityEditModel>() : camapign.CampaignActivity.ToList(); if (model.ActivityId <= 0) { var activity = campaignActivities.OrderBy(x => x.Sequence).LastOrDefault(); model.Sequence = activity.Sequence + 1; campaignActivities.Add(model); } else { campaignActivities = campaignActivities.Where(x => x.ActivityId != model.ActivityId).ToList(); campaignActivities.Add(model); } var IsValid = IsValidActivity(campaignActivities); if (!IsValid) { model.FeedbackMessage = FeedbackMessageModel.CreateWarningMessage("First activity can not be Outbound Call"); } model.IsValid = IsValid; var orgId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId; if (IsValid) { _campaignService.EditActivity(orgId, model); } if (model.IsValid) { model.FeedbackMessage = FeedbackMessageModel.CreateSuccessMessage("Successfully updated"); } } return(View("EditActivityModel", model)); }