public async Task <string> GenerateProductPackingCodeByCompositeId(FabricProductPackingCompositeIdFormDto form) { var fabricSKU = await _fabricProductSKURepository.ReadByIdAsync(form.SKUId.GetValueOrDefault()); var uom = await _uomService.GetById(form.PackingUOMId.GetValueOrDefault()); if (fabricSKU != null && uom != null) { var clientNow = DateTime.Now.AddHours(_identityProvider.TimezoneOffset); var packingSizeRoundedString = Math.Round(form.PackingSize.GetValueOrDefault(), 2).ToString().Replace(".", "").Replace(",", ""); var code = fabricSKU.Code + packingSizeRoundedString + uom.Unit; if (!_productPackingRepository.ReadAll().Any(entity => entity.Code == code)) { //var packingModel = new ProductPackingModel(fabricSKU.ProductSKUID, uom.Id, form.PackingSize.GetValueOrDefault(), code, code); //var packingId = await _productPackingRepository.InsertAsync(packingModel); //var fabricPacking = new FabricProductPackingModel(code, fabricSKU.Id, fabricSKU.ProductSKUID, packingId, uom.Id, form.PackingSize.GetValueOrDefault()); //await _fabricProductPackingRepository.InsertAsync(fabricPacking); } return(code); } return(string.Empty); }
public ActionResult Edit(long id) { ViewBag.UOMNames = new SelectList(UOMService.GetAllByIsStandardUOM(true), "UOMName", "UOMName"); var UOM = new UOM(); UOM = UOMService.GetById(id); return(View(UOM)); }
public async Task <IActionResult> GetById([FromRoute] int id) { try { var data = await _service.GetById(id); if (data == null) { return(NotFound()); } return(Ok(new { data, statusCode = HttpStatusCode.OK })); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }