Ejemplo n.º 1
0
        public string NotificationPush(NotifiationViewModel notification)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    OperationsStatusViewModel OperationsStatusViewModelObj = null;
                    //INSERT
                    notification.logDetailsObj = new LogDetailsViewModel();
                    //Getting UA
                    notification.logDetailsObj.CreatedBy   = _commonBusiness.GetUA().UserName;
                    notification.logDetailsObj.CreatedDate = _commonBusiness.GetCurrentDateTime();
                    if (notification.CustomerName == "All")
                    {
                        OperationsStatusViewModelObj = Mapper.Map <OperationsStatus, OperationsStatusViewModel>(_notificationBusiness.NotificationMobilePush(Mapper.Map <NotifiationViewModel, Notification>(notification)));
                    }
                    else
                    {
                        string[] CustomerIDList = notification.CustomerIDList != null?notification.CustomerIDList.Split(',') : null;

                        foreach (string cid in CustomerIDList)
                        {
                            notification.customer.ID     = int.Parse(cid);
                            OperationsStatusViewModelObj = Mapper.Map <OperationsStatus, OperationsStatusViewModel>(_notificationBusiness.NotificationMobilePush(Mapper.Map <NotifiationViewModel, Notification>(notification)));
                        }
                    }
                    return(JsonConvert.SerializeObject(new { Result = "OK", Record = OperationsStatusViewModelObj }));
                }
                catch (Exception ex)
                {
                    return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
                }
            }
            //Model state errror
            else
            {
                List <string> modelErrors = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        modelErrors.Add(modelError.ErrorMessage);
                    }
                }
                return(JsonConvert.SerializeObject(new { Result = "VALIDATION", Message = string.Join(",", modelErrors) }));
            }
        }
Ejemplo n.º 2
0
        public string GetNotification(string ID)
        {
            try
            {
                NotifiationViewModel NotifObj = null;
                if (!string.IsNullOrEmpty(ID))
                {
                    NotifObj = Mapper.Map <Notification, NotifiationViewModel>(_notificationBusiness.GetNotification(Int32.Parse(ID)));
                }

                return(JsonConvert.SerializeObject(new { Result = "OK", Record = NotifObj }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
            }
        }