public void AddCatagory() { var catagory = new Catagory { CatagoryName= "Vehicles", CreatedDate = DateTime.Now }; response = client.AddCatagory(catagory); Assert.IsTrue(response.IsSuccessFull); }
public void TestFindByIdAndCheckFetchCatagory() { IArtistDao dao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase()); Artist artist = dao.findById(1); Assert.AreEqual(artist.Id, 1); Assert.AreEqual(artist.Name, "Larry Page"); ICatagoryDao catDao = DALFactory.CreateCatagoryDao(DALFactory.CreateDatabase()); Catagory cat = catDao.findById(1); Assert.AreEqual(artist.Catagory.Id, cat.Id); }
public bool Add(Catagory catagory) { SqlConnection con = new SqlConnection(@"server=TANVIR; database=Stock Management System current;integrated security=true"); string query = @"INSERT INTO Category([Category Name]) VALUES ('" + catagory.Name + "')"; SqlCommand commend = new SqlCommand(query, con); con.Open(); bool isValid = commend.ExecuteNonQuery() > 0; con.Close(); return(isValid); }
private static void CreateCatagories() { Console.WriteLine("Insert Catagories "); ICatagoryDao catagoryDao = DALFactory.CreateCatagoryDao(DALFactory.CreateDatabase()); for (int i = 1; i <= 10; i++) { Catagory c = new Catagory(); c.Name = "Catagory " + i; c.Description = "Catagory Description for " + i; catagoryDao.Insert(c); } }
public ActionResult Create([Bind(Include = "CategoryId,CategoryName,CategoryDescription,CategoryActive,CategoryDate,CategoryDateUpdate")] Catagory catagory) { catagory.CategoryDate = DateTime.Now; catagory.CategoryDateUpdate = DateTime.Now; if (ModelState.IsValid) { db.Catagories.Add(catagory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catagory)); }
public int UpdateCatagoryById(Catagory catagory) //Mathod for Updating a Catagory { string query = "UPDATE Catagories SET CatagoryName = @catagoryName WHERE Id = " + catagory.Id; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@catagoryName", catagory.CatagoryName); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return(rowAffected); }
public int SaveCatagory(Catagory catagory) //Mathod for saving Catagory { string query = "INSERT INTO Catagories(CatagoryName) VALUES(@catagoryName)"; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@catagoryName", catagory.CatagoryName); //Inserting value in a Hackprotected way connection.Open(); int rowAffect = command.ExecuteNonQuery(); connection.Close(); return(rowAffect); }
public CActionLogFormat(Catagory logCategory, string equipmentName, string contents) : base(logCategory, "ACTION", "ACTION") { try { _contents.Add(equipmentName); _contents.Add(contents); } catch (Exception ex) { CLogManager.Instance.Log(new CExceptionLogFormat(Catagory.Error, CExceptionLogFormat.DEFAULT_KEY, ex)); } }
public int Save(Catagory aCatagory) { Query = "INSERT INTO CatagoryTable(Catagory) VALUES(@catagory)"; Command = new SqlCommand(Query, Connection); Command.Parameters.Clear(); Command.Parameters.Add("@catagory", SqlDbType.VarChar); Command.Parameters["@catagory"].Value = aCatagory.CatagoryName; Connection.Open(); int rowAffected = Command.ExecuteNonQuery(); Connection.Close(); return(rowAffected); }
public CHostLogFormat(Catagory logCategory, string msgName, string contents) : base(logCategory, "HOST", "HOST") { try { _contents.Add(msgName); _contents.Add(contents); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public string LastAddedCategory() { try { int? dNumber = _context.Catagory.Where(db => db.Date >= DateTime.Now.AddDays(-3)).Max(u => (int?)u.CatagoryId); Catagory catName = _context.Catagory.Where(db => db.CatagoryId == (int)dNumber).SingleOrDefault(); return(catName.CatagoryName); } catch { return("Nill"); } }
public CMaterialDataLogFormat(Catagory logCategory, string action, string contents) : base(logCategory, "SYSTEM", "METERIAL_DATA") { try { _contents.Add(action); _contents.Add(contents); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
//customer/edit/id public IActionResult Edit(int?id) { if (id != null && id > 0) { Catagory existingCatagory = _catagoryManager.GetById(id); if (existingCatagory != null) { return(View(existingCatagory)); } } return(View()); }
public string UpdateStudentById(Catagory catagory) { int rowAffect = catagoryGetway.UpdateCatagoyById(catagory); if (rowAffect > 0) { return("Update Successful"); } else { return("Update Failed"); } }
public CAlarmLogFormat2(Catagory logCategory, string logKey, string equipmentName, string contents) : base(logCategory, logKey, "ALARM") { try { _contents.Add(equipmentName); _contents.Add(contents); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public async Task <IActionResult> Create([Bind("CatagoryId,CatagoryName")] Catagory catagory) { catagory.Date = DateTime.Today.Date; if (ModelState.IsValid) { _context.Add(catagory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(catagory)); }
public CStatusLogFormat(Catagory logCategory, string logKey, string equipmentName, string contents) : base(logCategory, "STATUS", "STATUS") { try { _contents.Add(equipmentName); _contents.Add(contents); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public string DeleteCatagoryById(Catagory catagory) { int rowAffect = catagoryGetway.DeleteCatagoyById(catagory); if (rowAffect > 0) { return("Delete Successful"); } else { return("Delete Failed"); } }
public ActionResult Create([Bind(Include = "Id,Label,Type")] Catagory catagory) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); catagory.User = _userManager.FindById(userId); db.Catagories.Add(catagory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catagory)); }
public IHttpActionResult Delete([FromODataUri] int key) { Catagory catagory = db.Catagory.Find(key); if (catagory == null) { return(NotFound()); } db.Catagory.Remove(catagory); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
// GET: Instructor/Catagories/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Catagory catagory = await db.catagories.FindAsync(id); if (catagory == null) { return(HttpNotFound()); } return(View(catagory)); }
public Catagory[] GetAll() { string query = "SELECT * FROM Catagories"; DataTable dataTable = dataHelper.ExecuteQuery(query); int length = dataTable.Rows.Count; Catagory[] catagories = new Catagory[length]; for (int i = 0; i < length; i++) { Catagory catagory = RowToCatagory(dataTable.Rows[i]); catagories[i] = catagory; } return(catagories); }
public string SaveCatagory(Catagory catagory) //Checking Saving succesful or not { if (catagoryGateway.IsCatagoryExist(catagory.CatagoryName)) { return("Catagory Already Exist..."); } int rowAffect = catagoryGateway.SaveCatagory(catagory); if (rowAffect > 0) { return("Save Succesful"); } return("Save Failed"); }
public bool Add(Catagory catagory) { int isExecuted = 0; db.Catagories.Add(catagory); isExecuted = db.SaveChanges(); if (isExecuted > 0) { return(true); } return(false); }
/// <summary> /// Catagory, 화면명, 내용, 추가 내용 /// </summary> /// <param name="logCatagory"></param> /// <param name="displayName"></param> /// <param name="contents"></param> /// <param name="remark"></param> public CUILogFormat(Catagory logCatagory, string displayName, string contents, string remark) : base(logCatagory, "SYSTEM", "UI") { try { _contents.Add(displayName); _contents.Add(contents); _contents.Add(remark); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
// DELETE: api/Catagories/5 public IHttpActionResult DeleteCatagory(int id) { Catagory catagory = db.Catagories.Find(id); if (catagory == null) { return(NotFound()); } db.Catagories.Remove(catagory); db.SaveChanges(); return(Ok(catagory)); }
public static IZombie Make(Catagory catagory, IsRange isRange, ZombieColor color) { ZombieFactory factory = null; if (catagory == Catagory.Crazy) { factory = new CrazyZombieFactory(); } else if (catagory == Catagory.Normal) { factory = new NormalZombieFactory(); } return(factory.Build(isRange, color)); }
public CControlLogFormat(Catagory logCatagory, string controlName, string attributeName, string value) : base(logCatagory, "CONTROL", "CONTROL") { try { _contents.Add(controlName); _contents.Add(attributeName); _contents.Add(value); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
// GET: Catagories/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Catagory catagory = db.Catagories.Find(id); if (catagory == null) { return(HttpNotFound()); } return(View(catagory)); }
//Get: Catagories/DeleteCatagory/id public ActionResult DeleteCatagory(int id) { using (ApplicationDbContext db = new ApplicationDbContext()) { //Get the category Catagory CAT = db.Catagories.Find(id); //Remove the category db.Catagories.Remove(CAT); //Save db.SaveChanges(); } //Redirect return(RedirectToAction("Index")); }
public CStatusLogFormat(Catagory logCategory, string logKey, string GlassID, string GlassCode, string contents, string Position) : base(logCategory, "FLOW", "FLOW") { try { _contents.Add(GlassID); _contents.Add(GlassCode.ToString()); _contents.Add(contents); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public static int Save(Catagory catagory) { return CatagoryData.Save(catagory); }
internal static int Save(Catagory catagory) { using (OleDbCommand cmd = new OleDbCommand()) { try { string SaveString = "INSERT INTO Catagory (CatagoryName, Description)VALUES(@CatagoryName,@Description)"; string UpdateString = "UPDATE Catagory SET CatagoryName =@CatagoryName, Description =@Description where CatagoryID=" + catagory.CatagoryID + ";"; cmd.Parameters.Add(new OleDbParameter("@CatagoryName", OleDbType.VarChar, 250)); cmd.Parameters.Add(new OleDbParameter("@Description", OleDbType.VarChar, 25000)); cmd.Parameters["@CatagoryName"].Value = catagory.CatagoryName; cmd.Parameters["@Description"].Value = catagory.Description; if (catagory.CatagoryID == 0) { cmd.CommandText = SaveString; } else { cmd.CommandText = UpdateString; } int a = BaseDB.ExecuteNonQuery(cmd); return a; } catch (Exception e) { throw e; } } }
protected void btnSave_Click(object sender, EventArgs e) { try { Catagory catagory = new Catagory(); catagory.CatagoryName = txtName.Text; catagory.Description = " "; List<Catagory> catagories = Catagory.GetCatagoryByName(txtName.Text.Trim()); string catagoryID = Request.QueryString["ID"]; if (string.IsNullOrEmpty(catagoryID)) { if (catagories.Count==0) { int rowAfected = Catagory.Save(catagory); if (rowAfected > 0) { divMessage.Visible = true; lblMeessage.Text = "Save Success"; resetFields(); } } else { divMessage.Visible = true; lblMeessage.Text = "Duplicate catagory"; } } else { int id = Convert.ToInt16(catagoryID); Catagory catagorybyid = Catagory.GetCatagoryBYID(id); if (catagorybyid.CatagoryName == txtName.Text.Trim()) { catagory.CatagoryID = id; int rowAfected = Catagory.Save(catagory); if (rowAfected > 0) { Response.Redirect("Default.aspx"); } } else { if (catagories.Count == 0) { catagory.CatagoryID = id; int rowAfected = Catagory.Save(catagory); if (rowAfected > 0) { Response.Redirect("Default.aspx"); } } else { divMessage.Visible = true; lblMeessage.Text = "Duplicate catagory"; } } } } catch(Exception ex) { divMessage.Visible = true; lblMeessage.Text = "Save failed"+ex.Message; } }