示例#1
0
        public void AddCatagory()
        {
            var catagory = new Catagory
            {
                CatagoryName= "Vehicles",
                CreatedDate = DateTime.Now
            };
            response = client.AddCatagory(catagory);

            Assert.IsTrue(response.IsSuccessFull);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
            }
        }
示例#5
0
        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));
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
 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));
     }
 }
示例#9
0
        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);
        }
示例#10
0
 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);
     }
 }
示例#11
0
 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);
     }
 }
示例#13
0
        //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");
            }
        }
示例#15
0
 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);
     }
 }
示例#16
0
        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));
        }
示例#17
0
 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));
        }
示例#20
0
        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));
      }
示例#22
0
        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");
        }
示例#24
0
        public bool Add(Catagory catagory)
        {
            int isExecuted = 0;

            db.Catagories.Add(catagory);
            isExecuted = db.SaveChanges();

            if (isExecuted > 0)
            {
                return(true);
            }

            return(false);
        }
示例#25
0
 /// <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);
     }
 }
示例#26
0
        // 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));
        }
示例#27
0
    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));
    }
示例#28
0
 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);
     }
 }
示例#29
0
        // 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));
        }
示例#30
0
 //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"));
 }
示例#31
0
 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;
        }
    }