Exemplo n.º 1
0
        public bool AddProductUnitTypes(ProductUnitTypeModel productUnitType)
        {
            int pk;

            try
            {
                if (!_productUnitTypeRepo.AsQueryable().Any())
                {
                    pk = 0;
                }
                else
                {
                    pk = _productUnitTypeRepo.GetMaxPK("UnitTypeIds");
                }

                _productUnitTypeRepo.Add(new ProductUnitType
                {
                    UnitTypeIds   = pk + 1,
                    UnitTypeNames = productUnitType.UnitTypeName,
                    Status        = CommonConstants.StatusTypes.Active
                });

                return(true);
            }
            catch (Exception ex)
            {
                _productUnitTypeRepo.Rollback();

                if (!_crashLogRepo.AsQueryable().Any())
                {
                    pk = 0;
                }
                else
                {
                    pk = _crashLogRepo.GetMaxPK("CrashLogId") + 1;
                }

                string msg = (string.IsNullOrEmpty(ex.Message) || ex.Message.ToLower().Contains(CommonConstants.MsgInInnerException.ToLower()))
                            ? ex.InnerException.Message
                            : ex.Message;
                _crashLogRepo.Add(new Crashlog
                {
                    CrashLogId   = pk,
                    ClassName    = "ProductService",
                    MethodName   = "AddProductUnitTypes",
                    ErrorMessage = ex.Message,
                    ErrorInner   = msg,
                    Data         = JsonSerializer.Serialize(productUnitType),
                    TimeStamp    = DateTime.Now
                });

                return(false);
            }
        }
Exemplo n.º 2
0
 public IActionResult AddProductUnitTypes(ProductUnitTypeModel purchaseModel)
 {
     if (_productService.AddProductUnitTypes(purchaseModel))
     {
         return(Ok(new { Response = "Success" }));
     }
     else
     {
         return(Conflict(new { Response = CommonConstants.HttpResponseMessages.Exception }));
     }
 }