public CallCodeModel GetCallCodeForEvent(string internalEventCode) { CallCodeModel model = null; StringBuilder sql = new StringBuilder(); sql.AppendFormat("SELECT * FROM CALL_CODE_LOOKUP WHERE CALL_CODE_TO_USE = '{0}'", internalEventCode); try { var data = _provider.GetData(sql.ToString(), null); LogInfo(string.Format("Fetching call code for event code {0}. QUERY: {1}", internalEventCode, sql.ToString())); if (data != null) { var row = data.Rows[0]; model = new CallCodeModel(); model.CALL_CODE_DEF = row["CALL_CODE_DEF"].Parse <long>(); } } catch (Exception e) { LogError(e); } return(model); }
public async Task <ActionResult> Edit(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var entity = await db.CallCodes.FindAsync(id); if (entity == null) { return(HttpNotFound()); } var model = new CallCodeModel { Name = entity.Name, Code = entity.Code, Behavior = entity.Behavior, IsSuccess = entity.IsSuccess }; return(View(model)); } catch (Exception e) { AddAlert($"Oops! something went wrong. Error code: {e.HResult}", "Edit", this.GetType().ToString(), AlertType.error, e); return(View(new ProjectModel())); } }
public async Task <ActionResult> Edit(CallCodeModel model) { try { if (ModelState.IsValid) { var entity = await db.CallCodes.FindAsync(model.Id); if (entity == null) { return(HttpNotFound()); } entity.Name = model.Name; entity.Code = model.Code; entity.Behavior = model.Behavior; entity.IsSuccess = model.IsSuccess; entity.LastUpdate = DateTime.Now; db.Entry(entity).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); } catch (Exception e) { AddAlert($"Oops! something went wrong. Error code: {e.HResult}", "Edit(model)", this.GetType().ToString(), AlertType.error, e); return(View(model)); } }
public async Task <ActionResult> Create(CallCodeModel model) { try { if (ModelState.IsValid) { var campaign = await db.Campaigns .SingleOrDefaultAsync(x => !x.IsDeleted && x.Id == model.CampaignId); if (campaign == null) { AddAlert("Campaign not found", AlertType.error); return(RedirectToAction("Index")); } var callCode = new CallCode( campaign, model.Name, model.Code, model.Behavior, model.IsSuccess, DateTime.Now); db.CallCodes.Add(callCode); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } } catch (Exception e) { AddAlert($"Oops! something went wrong. Error code: {e.HResult}", "Create(model)", GetType().ToString(), AlertType.error, e); } return(View(model)); }