public DbResponse <int> Acceptance(WarrantyAcceptanceModel model, string userName) { try { if (_db.Warranty.IsInWarranty(model.ProductStockId)) { return(new DbResponse <int>(false, $"Product already accepted in Warranty")); } var registrationId = _db.Registrations.GetRegID_ByUserName(userName); if (registrationId == 0) { return(new DbResponse <int>(false, $"Invalid User")); } //Product Logs var logs = new ProductLogAddModel { SellingId = model.SellingId, ProductStockId = model.ProductStockId, ActivityByRegistrationId = registrationId, Details = $"Product Accepted for warranty", LogStatus = ProductLogStatus.WarrantyAcceptance }; _db.ProductLog.Add(logs); return(_db.Warranty.Acceptance(model)); } catch (Exception e) { return(new DbResponse <int>(false, $"{e.Message}. {e.InnerException?.Message ?? ""}")); } }
//Post Acceptance(ajax) public IActionResult PostAcceptance(WarrantyAcceptanceModel model) { var response = _warranty.Acceptance(model, User.Identity.Name); return(Json(response)); }