public ActionResult Create(CenterCreate model) { if (ModelState.IsValid) { } return(View(model)); }
protected void saveButton_Click(object sender, EventArgs e) { CenterCreate aCenterCreate = new CenterCreate(); ShowCenterUI aShowCenterUi = new ShowCenterUI(); aCenterCreate.Name = centerNameTextBox.Text; string thana = thanaDropDownList.SelectedItem.ToString(); aCenterCreate.ThanaID = aCenterCreateManager.GetIDByThanaName(thana); aCenterCreate.DistrictID = aCenterCreateManager.GetDistrictIDByThanaName(thana); aCenterCreate.Code = GenerateCode(thana); aCenterCreate.Password = CreateRandomPassword(); if (aCenterCreate.Name != "") { showLabel.Text = aCenterCreateManager.Save(aCenterCreate); Session["Name"] = centerNameTextBox.Text; Session["Code"] = aCenterCreate.Code; Session["Password"] = aCenterCreate.Password; Response.Redirect("ShowCenterUI.aspx"); } else { showLabel.Text = "Not saved. Please enter information correctly."; } }
public string Save(CenterCreate aCenterCreate) { if (aCenterCreateGateway.Save(aCenterCreate) > 0) { return("Data saved Sccessfully."); } else { return("Data not saved."); } }
public int Save(CenterCreate aCenterCreate) { SqlConnection connection = new SqlConnection(connectionstring); string query = "insert into tbl_CenterCreate values ('" + aCenterCreate.Name + "','" + aCenterCreate.ThanaID + "','" + aCenterCreate.DistrictID + "','" + aCenterCreate.Code + "','" + aCenterCreate.Password + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return(rowAffected); }
public bool CreateCenter(CenterCreate model) { var entity = new Center() { Name = model.Name, City = model.City, State = model.State, Country = model.Country }; using (var ctx = new ApplicationDbContext()) { ctx.Centers.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(CenterCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateCenterService(); if (service.CreateCenter(model)) { TempData["SaveResult"] = "Your note was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Note could not be created."); return(View(model)); }
public List <CenterCreate> CenterList(string thana) { int thanaID = GetThanaIDByThana(thana); SqlConnection connection = new SqlConnection(connectionstring); string query = "select * from tbl_CenterCreate where ThanaID = '" + thanaID + "'"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <CenterCreate> centerList = new List <CenterCreate>(); while (reader.Read()) { CenterCreate aCenterCreate = new CenterCreate(); aCenterCreate.ID = int.Parse(reader["ID"].ToString()); aCenterCreate.Name = reader["Name"].ToString(); centerList.Add(aCenterCreate); } reader.Close(); connection.Close(); return(centerList); }