public async Task <IActionResult> MapGlueIngredient(GlueIngredient glueIngredient) { glueIngredient.CreatedDate = DateTime.Now.ToString("MMMM dd, yyyy HH:mm:ss tt"); if (await _glueIngredientService.MapGlueIngredient(glueIngredient)) { return(NoContent()); } else { return(NoContent()); } //throw new Exception("Creating the brand failed on save"); }
public async Task <IActionResult> MapGlueIngredient(GlueIngredient glueIngredient) { //if (await _glueIngredientService.CheckExists(glueIngredientDto.ID)) // return BadRequest("Glue ID already exists!"); //if (await _glueIngredientService.CheckBarCodeExists(glueIngredientDto.Code)) // return BadRequest("Barcode already exists!"); ////var username = User.FindFirst(ClaimTypes.Name).Value; ////glueIngredientDto.Updated_By = username; glueIngredient.CreatedDate = DateTime.Now.ToString("MMMM dd, yyyy HH:mm:ss tt"); if (await _glueIngredientService.MapGlueIngredient(glueIngredient)) { return(NoContent()); } throw new Exception("Creating the brand failed on save"); }
public async Task <bool> MapGlueIngredient(GlueIngredient glueIngredient) { if (glueIngredient.Position.IsNullOrEmpty()) { return(false); } var item = await _repoGlueIngredient.FindAll().FirstOrDefaultAsync(x => x.GlueID == glueIngredient.GlueID && x.IngredientID == glueIngredient.IngredientID); if (item == null) { _repoGlueIngredient.Add(glueIngredient); return(await _repoGlueIngredient.SaveAll()); } else { item.Percentage = glueIngredient.Percentage; item.Allow = glueIngredient.Allow; item.Position = glueIngredient.Position; return(await _repoGlueIngredient.SaveAll()); } }
public async Task <bool> MapGlueIngredient(GlueIngredient glueIngredient) { _repoGlueIngredient.Add(glueIngredient); return(await _repoGlueIngredient.SaveAll()); }