public int AddRecipient(string ObserveId, string Email) { ObservesModel model = ObserveServiceManager.GetObserveById(ObserveId); if (model.Users.Id == User.Identity.GetUserId()) { List <RecipientsModel> list = ObserveServiceManager.GetRecipientList(ObserveId); if (list.Where(e => e.Email == Email).Count() == 0) { RecipientsModel newModel = new RecipientsModel() { Id = Guid.NewGuid().ToString(), Observes = model, Email = Email, Deleted = false }; ObserveServiceManager.AddRecipient(newModel); return(1); } else { return(3); } } else { return(2); } }
public JsonResult GetRecipientList(string ObserveId) { ObservesModel model = ObserveServiceManager.GetObserveById(ObserveId); if (model.Users.Id == User.Identity.GetUserId()) { List <RecipientsModel> listModel = ObserveServiceManager.GetRecipientList(ObserveId); List <RecipientListOutputModel> output = new List <RecipientListOutputModel>(); foreach (RecipientsModel item in listModel) { RecipientListOutputModel outputModel = new RecipientListOutputModel() { RecipientId = item.Id, Email = item.Email }; output.Add(outputModel); } return(Json(output)); } else { return(Json(JsonConvert.DeserializeObject("{ 'Status': 'Unauthorized' }"))); } }
public JsonResult GetStepList(String ObserveId) { ObservesModel observesModel = ObserveServiceManager.GetObserveById(ObserveId); if (observesModel.Users.Id == User.Identity.GetUserId()) { List <StepsModel> modelList = StepServiceManager.GetStepListByObserveId(ObserveId); List <StepListOutputModel> newList = new List <StepListOutputModel>(); foreach (StepsModel item in modelList) { string StringMethod = null; string StringSetHeader = null; if (item.Method == 1) { StringMethod = "GET"; } else if (item.Method >= 2) { StringMethod = "POST"; } if (item.SetHeader == 1) { StringSetHeader = "Yes"; } else if (item.SetHeader == 0) { StringSetHeader = "No"; } else if (item.SetHeader == 2) { StringSetHeader = "Pre"; } StepListOutputModel newModel = new StepListOutputModel() { Id = item.Id, Priority = item.Order.GetValueOrDefault(), Url = item.Url, Method = StringMethod, SetHeader = StringSetHeader }; newList.Add(newModel); } return(Json(newList)); } else { return(Json(JsonConvert.DeserializeObject("{ 'Status' = 'Unauthorized Access' }"))); } }
public int DeleteObserveById(string Id) { ObservesModel model = ObserveServiceManager.GetObserveById(Id); if (model.Users.Id == User.Identity.GetUserId()) { ObserveServiceManager.DeleteObserveById(Id); return(1); } else { return(2); } }
public int SetIntervalByObserveId(string ObserveId, int Interval) { ObservesModel model = ObserveServiceManager.GetObserveById(ObserveId); if (model.Users.Id == User.Identity.GetUserId()) { ObserveServiceManager.SetIntervalByObserveId(ObserveId, Interval); return(1); } else { return(2); } }
public int SetObserveName(string Id, string Name) { ObservesModel model = ObserveServiceManager.GetObserveById(Id); if (model.Users.Id == User.Identity.GetUserId()) { model.Name = Name; ObserveServiceManager.UpdateObserve(model); return(1); } else { return(2); } }
public int SetObserveStatus(string Id, int Status) { ObservesModel model = ObserveServiceManager.GetObserveById(Id); if (model.Users.Id == User.Identity.GetUserId()) { model.Status = Status; ObserveServiceManager.UpdateObserve(model); return(1); } else { return(2); } }
public int ReorderStep(ReorderStepInputModel model) { ObservesModel observesModel = ObserveServiceManager.GetObserveById(model.ObserveId); if (observesModel.Users.Id == User.Identity.GetUserId()) { if (model.initOrder == model.minOrder) { StepServiceManager.ReorderStepDesc(model.ObserveId, model.minOrder, model.maxOrder); return(1); } else { StepServiceManager.ReorderStepAsc(model.ObserveId, model.minOrder, model.maxOrder); return(1); } } else { return(2); } }
public ActionResult Modify(string id) { if (Request.Browser.IsMobileDevice) { return(RedirectToAction("ModifyM")); } ObservesModel model = ObserveServiceManager.GetObserveById(id); List <StepsModel> oriList = StepServiceManager.GetStepListByObserveId(id); List <PCMethodsModel> methodList = PCMethodServiceManager.GetPCMethodList().OrderBy(e => e.Name).ToList(); List <StepListOutputModel> newList = new List <StepListOutputModel>(); List <PCMethodOutputModel> PCMethodOutput = new List <PCMethodOutputModel>(); foreach (StepsModel item in oriList) { string StringMethod = null; string StringSetHeader = null; if (item.Method == 1) { StringMethod = "GET"; } else if (item.Method >= 2) { StringMethod = "POST"; } if (item.SetHeader == 1) { StringSetHeader = "Yes"; } else if (item.SetHeader == 0) { StringSetHeader = "No"; } else if (item.SetHeader == 2) { StringSetHeader = "Pre"; } StepListOutputModel newModel = new StepListOutputModel() { Id = item.Id, Priority = item.Order.GetValueOrDefault(), Url = item.Url, Method = StringMethod, SetHeader = StringSetHeader }; newList.Add(newModel); } foreach (PCMethodsModel item in methodList) { PCMethodOutputModel newModel = new PCMethodOutputModel() { Id = item.Id, Name = item.Name }; PCMethodOutput.Add(newModel); } try { ObserveOutputModel output = new ObserveOutputModel() { Id = model.Id, Name = model.Name, Status = model.Status.GetValueOrDefault(), Interval = model.Interval.GetValueOrDefault(), StepList = newList, PCMethod = PCMethodOutput }; return(View(output)); } catch (NullReferenceException e) { return(RedirectToAction("Index", "Observe")); } }