Exemple #1
0
        public async Task <ActionResult <ProductTypeRegRespObj> > AddUpdateProductAsync([FromBody] ProductTypeObj entity)
        {
            try
            {
                credit_producttype item = null;
                if (entity.ProductTypeId > 0)
                {
                    item = await _repo.GetProductTypeByIdAsync(entity.ProductTypeId);

                    if (item == null)
                    {
                        return new ProductTypeRegRespObj
                               {
                                   Status = new APIResponseStatus {
                                       IsSuccessful = false, Message = new APIResponseMessage {
                                           FriendlyMessage = "Item does not Exist"
                                       }
                                   }
                               }
                    }
                    ;
                }

                var isDone = _repo.AddUpdateProductType(entity);
                return(new ProductTypeRegRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = isDone ? true : false, Message = new APIResponseMessage {
                            FriendlyMessage = isDone ? "successful" : "Unsuccessful"
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                var errorCode = ErrorID.Generate(5);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new ProductTypeRegRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage {
                            FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                        }
                    }
                });
            }
        }