Esempio n. 1
0
        public async Task <IActionResult> PostStoreRouteAsync(
            [FromBody] StoreForCreationUiModel storeForCreationUiModel)
        {
            var userAudit = await _inquiryUserProcessor.GetUserByLoginAsync(GetEmailFromClaims());

            if (userAudit == null)
            {
                userAudit = new UserUiModel()
                {
                    Id = Guid.NewGuid()
                };
                //return BadRequest("AUDIT_USER_NOT_EXIST");
            }

            var newCreatedStore =
                await _createStoreProcessor.CreateStoreAsync(userAudit.Id, storeForCreationUiModel);

            switch (newCreatedStore.Message)
            {
            case ("SUCCESS_CREATION"):
            {
                Log.Information(
                    $"--Method:PostStoreRouteAsync -- Message:STORE_CREATION_SUCCESSFULLY -- " +
                    $"Datetime:{DateTime.Now} -- StoreInfo:{storeForCreationUiModel.StoreName}");
                return(Created(nameof(PostStoreRouteAsync), newCreatedStore));
            }

            case ("ERROR_ALREADY_EXISTS"):
            {
                Log.Error(
                    $"--Method:PostStoreRouteAsync -- Message:ERROR_STORE_ALREADY_EXISTS -- " +
                    $"Datetime:{DateTime.Now} -- StoreInfo:{storeForCreationUiModel.StoreName}");
                return(BadRequest(new { errorMessage = "STORE_ALREADY_EXISTS" }));
            }

            case ("ERROR_STORE_NOT_MADE_PERSISTENT"):
            {
                Log.Error(
                    $"--Method:PostStoreRouteAsync -- Message:ERROR_STORE_NOT_MADE_PERSISTENT -- " +
                    $"Datetime:{DateTime.Now} -- StoreInfo:{storeForCreationUiModel.StoreName}");
                return(BadRequest(new { errorMessage = "ERROR_CREATION_NEW_STORE" }));
            }

            case ("UNKNOWN_ERROR"):
            {
                Log.Error(
                    $"--Method:PostStoreRouteAsync -- Message:ERROR_CREATION_NEW_STORE -- " +
                    $"Datetime:{DateTime.Now} -- StoreInfo:{storeForCreationUiModel.StoreName}");
                return(BadRequest(new { errorMessage = "ERROR_CREATION_NEW_STORE" }));
            }
            }

            return(NotFound());
        }
Esempio n. 2
0
 public Task <StoreUiModel> CreateStoreAsync(Guid accountIdToCreateThisStore, StoreForCreationUiModel newStoreUiModel)
 {
     throw new NotImplementedException();
 }