public IHttpActionResult UpdateNotifications(NotificationModel entity)
        {
            var repository = new RepositoryNotification();
            var response   = new DataResponse();

            if (ModelState.IsValid)
            {
                var model = new EntityNotificationSettings
                {
                    UserId             = CurrentUserId,
                    Status             = entity.Status,
                    NotificationTypeId = entity.NotificationTypeId
                };

                response = repository.SaveNotification(model);
            }
            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 }));
            }
            response.Status  = DataResponseStatus.OK;
            response.Message = "Success";
            return(Ok <DataResponse>(response));
        }
        public DataResponse <EntityNotificationSettings> SaveNotification(EntityNotificationSettings entity)
        {
            DataResponse <EntityNotificationSettings> response = new DataResponse <EntityNotificationSettings>();

            try
            {
                base.DBInit();
                var model = DBEntity.UserNotificationMappers.FirstOrDefault(a => a.NotificationTypeId == entity.NotificationTypeId & a.UserId == entity.UserId);
                if (model != null)
                {
                    if (entity.Status != null)
                    {
                        model.Status    = entity.Status;
                        model.UpdatedBy = entity.UserId;
                        model.UpdatedOn = DateTime.UtcNow;
                    }
                    base.DBSaveUpdate(model);
                }
                else
                {
                    var data = DBEntity.UserNotificationMappers.Add(new Database.UserNotificationMapper
                    {
                        UserId             = entity.UserId,
                        NotificationTypeId = entity.NotificationTypeId,
                        Status             = entity.Status,
                        CreatedBy          = entity.UserId,
                        CreatedOn          = DateTime.UtcNow
                    });
                    base.DBSave(data);
                }
            }
            catch (Exception ex)
            {
                response.ThrowError(ex);
            }

            finally
            {
                base.DBClose();
            }
            return(response);
        }