public async Task <IActionResult> AddTemplateUI([FromBody] AppUitemplate model) { if (ModelState.IsValid) { try { logger.LogInformation("Adding Template in Repository"); var addedTempUI = await TempUIRepo.AddTemplateUIInfo(model); if (addedTempUI != null) { return(Ok(addedTempUI)); } else { return(NotFound()); } } catch (Exception excp) { logger.LogError("Error Adding Template in Repository " + excp.Message); return(BadRequest(excp)); } } return(BadRequest()); }
public async Task <AppUitemplate> UpdateTemplateInfo(AppUitemplate templateInfo) { if (db != null) { //Delete that post db.AppUitemplate.Update(templateInfo); //Commit the transaction await db.SaveChangesAsync(); } return(templateInfo); }
public async Task <AppUitemplate> AddTemplateUIInfo(AppUitemplate templateInfo) { if (db != null) { templateInfo.AppUitemplateId = Guid.NewGuid(); templateInfo.CreatedDate = DateTime.Now; await db.AppUitemplate.AddAsync(templateInfo); await db.SaveChangesAsync(); return(templateInfo); } return(templateInfo); }
public async Task <IActionResult> UpdateTempUI([FromBody] AppUitemplate TempUI) { if (ModelState.IsValid) { try { await TempUIRepo.UpdateTemplateInfo(TempUI); return(Ok()); } catch (Exception excp) { if (excp.GetType().FullName == "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException") { return(NotFound()); } return(BadRequest(excp)); } } return(BadRequest()); }