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 DataResponse <EntityNotificationType> UpdateNoificationTypeById(EntityNotificationType entity)
        {
            var response = new DataResponse <EntityNotificationType>();

            try
            {
                base.DBInit();

                var model = DBEntity.LookupNotificationTypes.FirstOrDefault(a => a.Id == entity.Id);
                model.Title           = entity.Title;
                model.NotificationKey = entity.NotificationKey;
                model.UpdatedOn       = entity.UpdatedOn;
                model.UpdatedBy       = entity.UpdatedBy;

                if (base.DBSaveUpdate(model) > 0)
                {
                    return(GetNoificationTypeById(model.Id));
                }
                else
                {
                    response.CreateResponse(DataResponseStatus.InternalServerError);
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }
            finally
            {
                base.DBClose();
            }
            return(response);
        }
        public DataResponse <EntityNotificationType> Insert(EntityNotificationType entity)
        {
            var response = new DataResponse <EntityNotificationType>();

            try
            {
                base.DBInit();

                var model = new Database.LookupNotificationType
                {
                    Title           = entity.Title,
                    NotificationKey = entity.NotificationKey,
                    CreatedBy       = entity.CreatedBy,
                    CreatedOn       = System.DateTime.UtcNow
                };

                if (base.DBSave(model) > 0)
                {
                    entity.Id = model.Id;
                    response.CreateResponse(entity, DataResponseStatus.OK);
                }
                else
                {
                    response.CreateResponse(DataResponseStatus.InternalServerError);
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }
            finally
            {
                base.DBClose();
            }
            return(response);
        }