public IHttpActionResult UpdateNotificationType(NotificationTypeModel model) { var response = new DataResponse <EntityNotificationType>(); if (ModelState.IsValid) { var entityNotificationType = new EntityNotificationType(); entityNotificationType.Id = model.Id; entityNotificationType.Title = model.Title; entityNotificationType.NotificationKey = model.NotificationKey; entityNotificationType.UpdatedBy = CurrentUserId; entityNotificationType.UpdatedOn = System.DateTime.UtcNow; response = repository.UpdateNoificationTypeById(entityNotificationType); return(Ok <DataResponse>(response)); } else { var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new { Key = s.Key.Split('.').Last(), Message = s.Value.Errors[0].ErrorMessage }); return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList })); } }
public ActionResult SetNotificationType(NotificationTypeModel model) { if (ModelState.IsValid) { MasterDetails _details = new MasterDetails(); Enums.CrudStatus status = _details.SetNotificationType(model, Enums.CrudType.Insert); ReturnAlertMessage(status); } return(RedirectToAction("GetNotificationType")); }
public ActionResult DeleteNotificationType(NotificationTypeModel model) { ViewBag.ShopList = WebSession.ShopList; if (ModelState.IsValid) { MasterDetails _details = new MasterDetails(); Enums.CrudStatus status = _details.SetNotificationType(model, Enums.CrudType.Delete); ReturnAlertMessage(status); } return(RedirectToAction("GetNotificationType")); }
public async Task <ActionResult> Notify([FromBody] NotificationTypeModel model) { var notificationHubClient = NotificationHubClient.CreateClientFromConnectionString(NotificationHubsApiKey, NotificationHubsNamespace); var message = new Message { Data = model }; try { var outcome = await notificationHubClient.SendFcmNativeNotificationAsync(JsonConvert.SerializeObject(message)); return(Ok()); } catch (Exception e) { return(StatusCode(500)); } }