Пример #1
0
        public HttpResponseMessage Update(LoMo.UserServices.DataContract.MerchantPreferences preferences)
        {
            Guid userId = Security.GetUserId();

            Log.Verbose("Start updating preferences for merchant user id {0}", userId);

            HttpResponseMessage errorResponse;

            if (preferences == null)
            {
                Log.Info("Invalid request. Update preferences failed for merchant user Id: {0}..merchantpreferences is null", userId);
                errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "request is empty");
                throw new HttpResponseException(errorResponse);
            }

            ScheduleType scheduleType;

            if (Enum.TryParse(preferences.EmailReportInterval, true, out scheduleType))
            {
                usersDal.UpdateMerchantSubscription(userId, SubscriptionType.TransactionReport, scheduleType, null);

                return(new HttpResponseMessage(HttpStatusCode.Accepted));
            }

            Log.Info("Invalid request. Update preferences failed for merchant user Id: {0}..scheduletype is invalid", userId);
            errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid schedule type");
            throw new HttpResponseException(errorResponse);
        }