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' }"))); } }