public Models.Item GetItemByID(Repository.Repository repository, int id)
        {
            string queryString = "select* from Item where id=" + id;

            repository.cmd.CommandText = queryString;

            using (DbDataReader reader = repository.cmd.ExecuteReader())
            {
                if (!reader.HasRows)
                {
                    return(new Models.Item());
                }
                else
                {
                    Models.Item temp = new Models.Item();
                    while (reader.Read())
                    {
                        temp = new Models.Item(
                            reader.GetInt32(0),
                            reader.GetString(1),
                            reader.GetString(2),
                            reader.GetInt64(3),
                            reader.GetInt64(4),
                            reader.GetString(5),
                            reader.GetBoolean(6));
                        break;
                    }
                    return(temp);
                }
            }
        }
        /// <summary>
        /// Delete the Sharefile items if Move flag is used
        /// </summary>
        private void DeleteShareFileItemRecursive(ShareFileClient client, Models.Item source, bool deleteFolder)
        {
            if (source is Models.Folder)
            {
                var children     = (source as Folder).Children;
                var childFiles   = children.OfType <Models.File>();
                var childFolders = children.OfType <Models.Folder>();

                RemoveShareFileItems(client, source, childFiles);

                if (Recursive)
                {
                    foreach (var childFolder in childFolders)
                    {
                        DeleteShareFileItemRecursive(client, childFolder, !KeepFolders);
                    }
                }

                if (deleteFolder)
                {
                    if (!HasChildren(client, source as Models.Folder))
                    {
                        RemoveShareFileItem(client, source);
                    }
                }
            }

            if (source is Models.File)
            {
                RemoveShareFileItem(client, source);
            }
        }
Beispiel #3
0
        public static List <Models.Item> getSp()
        {
            if (con != null && con.State == ConnectionState.Closed)
            {
                con.Open();                                                    // mở kết nối
            }
            List <Models.Item> l   = new List <Models.Item>();
            SqlCommand         cmd = new SqlCommand("Select * from sanPham", con);



            SqlDataReader rd = cmd.ExecuteReader();

            while (rd.Read() && rd != null)
            {
                Models.Item item = new Models.Item();
                item.Id  = rd.GetInt32(0);
                item.Ten = rd.GetString(1);
                item.Img = rd.GetString(2);
                l.Add(item);
            }
            rd.Close();   // <- too easy to forget
            rd.Dispose(); // <- too easy to forget
            con.Close();
            return(l);
        }
Beispiel #4
0
        /// <summary>
        /// Download all items recursively
        /// </summary>
        private void DownloadRecursive(ShareFileClient client, int downloadId, Models.Item source, DirectoryInfo target, ActionType actionType)
        {
            if (source is Models.Folder)
            {
                var subdir = CreateLocalFolder(target, source as Folder);

                var children = client.Items.GetChildren(source.url).Execute();

                if (children != null)
                {
                    ActionManager actionManager = new ActionManager();

                    foreach (var child in children.Feed)
                    {
                        if (child is Models.Folder && Recursive)
                        {
                            DownloadRecursive(client, downloadId, child, subdir, actionType);
                        }
                        else if (child is Models.File)
                        {
                            DownloadAction downloadAction = new DownloadAction(FileSupport, client, downloadId, (Models.File)child, subdir, actionType);
                            actionManager.AddAction(downloadAction);
                        }
                    }

                    actionManager.Execute();
                }
            }
        }
        public async Task <IActionResult> AddProcess([Bind("Title,ImgURL,Details,Price")] Models.Item item)
        {
            item.OwnerName = User.Identity.Name;
            await _itemsService.AddItemAsync(item);

            return(Redirect("/Home"));
        }
Beispiel #6
0
        public MainPageViewModel()
        {
            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(1)
            };

            timer.Tick += (s, e) =>
            {
                this.SecondAngle = DateTime.Now.Second * (360 / 60);
                this.MinuteAngle = DateTime.Now.Minute * (360 / 60);
                this.HourAngle   = DateTime.Now.Hour * (360 / 12);
            };
            timer.Start();
            for (int i = 0; i < 60; i++)
            {
                var second = new Models.Item
                {
                    Text  = i.ToString(),
                    Angle = i * (360 / 60)
                };
                this.SecondTicks.Add(second);
            }
            for (int i = 0; i < 12; i++)
            {
                var hour = new Models.Item
                {
                    Text  = (i == 0) ? "12" : i.ToString(),
                    Angle = i * (360 / 12)
                };
                this.HoursTicks.Add(hour);
            }
        }
Beispiel #7
0
        private Models.Item GetItem(string code)
        {
            Models.Item itm = new Models.Item();

            DataTable itemTable = new DataTable("ITEM");

            SqlCommand cmd = new SqlCommand("SELECT * FROM [Item] WHERE [No]=@No", new SqlConnection(this.StringConnection));

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@No", code.Trim());

            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.SelectCommand = cmd;

            try
            {
                adapter.Fill(itemTable);
                if (itemTable.Rows.Count > 0)
                {
                    itm.No                = (string)itemTable.Rows[0]["No"];
                    itm.Description       = (string)itemTable.Rows[0]["Description"];
                    itm.Descripcion2      = (string)itemTable.Rows[0]["Descripcion 2"];
                    itm.PriceincludingVAT = (decimal)itemTable.Rows[0]["Price including VAT"];
                    itm.PricewithoutVAT   = (decimal)itemTable.Rows[0]["Price without VAT"];
                    itm.VAT               = (decimal)itemTable.Rows[0]["VAT"];
                    itm.Qty_Inventory     = (decimal)itemTable.Rows[0]["Qty. Inventory"];
                }
            }
            catch
            { }

            return(itm);
        }
        /// <summary>
        /// Edit SanPham
        /// </summary>
        /// <param name="index"></param>
        /// <param name="sp"></param>
        public void UpdateSanPham(Repository.Repository repository, Models.Item sp)
        {
            string queryString = "update Item set name='" + sp.name +
                                 "',type='" + sp.type +
                                 "',amount=" + sp.amount +
                                 ",minimum=" + sp.minimum +
                                 ",provider='" + sp.provider +
                                 "',isRequestImport=" + sp.isImportOrder.ToString() +
                                 " where id=" + sp.ID;

            repository.cmd.CommandText = queryString;
            try
            {
                repository.cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Có lỗi xảy ra trong quá trình cập nhật dữ liệu, vui lòng thử lại!\nChi tiết: " + ex.StackTrace,
                    "Lỗi",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            this.LoadSanPham(repository);
        }
        public void DeleteItem(int id)
        {
            var result = 0;

            Models.Item item     = new Models.Item();
            MyContext   _context = new MyContext();

            var get = _context.Items.Find(id);

            // pengecekan data di database
            if (get == null)
            {
                // jika tidak ada, maka akan menampilkan seperti berikut
                MessageBox.Show("Sorry, your data is not found");
            }
            else
            {
                // jika ada, maka akan mengubah status isDelete dan akan disimpan di database
                //getData.IsDelete = true;
                //getData.DeleteDate = DateTimeOffset.Now.LocalDateTime;


                // jika ada, maka akan didelete dan akan disimpan di database
                get.isDeleted = true;
                result        = _context.SaveChanges();
                if (result > 0)
                {
                    MessageBox.Show("Delete Successfully");
                }
                else
                {
                    MessageBox.Show("Delete Failed");
                }
            }
        }
        public void AddItem(string Iname, int Iqty, int Icat, string Uemail, string Uname, string Uroles)
        {
            var result = 0;

            Models.Item item     = new Models.Item();
            MyContext   _context = new MyContext();

            item.Name        = Iname;
            item.Quantity    = Iqty;
            item.Category_Id = Icat;
            item.isDeleted   = false;
            _context.Items.Add(item);
            result = _context.SaveChanges();

            for (int i = 0; i < Iqty; i++)
            {
                ItemDetail iDetail = new ItemDetail(Uemail, Uname, Uroles);
                iDetail.ShowDialog();
            }


            if (result > 0)
            {
                MessageBox.Show("Add Data Item Successful!");
            }
            else
            {
                MessageBox.Show("Add Data Item Failed!");
            }
        }
        public void UpdateItem(int id, string Iname, int Iqty, int Icat)
        {
            var result = 0;

            Models.Item item     = new Models.Item();
            MyContext   _context = new MyContext();

            var get = _context.Items.Find(id);

            if (get == null)
            {
                MessageBox.Show("Supplier not found!");
            }
            else
            {
                get.Name        = Iname;
                get.Quantity    = Iqty;
                get.Category_Id = Icat;
                result          = _context.SaveChanges();

                if (result > 0)
                {
                    MessageBox.Show("Update Success!");
                }
                else
                {
                    MessageBox.Show("Update Failed!");
                }
            }
        }
Beispiel #12
0
        public ActionResult Edit(Models.Item postback)
        {
            //verify the user input
            if (this.ModelState.IsValid)
            {
                using (DAL.BarContext db = new DAL.BarContext())
                {
                    //catch Item.Id and postback the data of Id
                    var result = (from s in db.Items where s.Id == postback.Id select s).FirstOrDefault();

                    //Save the change into Database
                    result.Name            = postback.Name; result.Price = postback.Price;
                    result.Description     = postback.Description; result.OnShelf = postback.OnShelf;
                    result.DefaultImageURL = postback.DefaultImageURL; result.Category = postback.Category;
                    result.ImageAlt        = postback.ImageAlt;

                    //Save the change
                    db.SaveChanges();

                    //Pop-up "edit successfully" msg and direct to Index
                    TempData["Message"] = String.Format("Item [{0}] is edited ", postback.Name);
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                return(View(postback));
            }
        }
        private int GenerateItems(CategoryTypesEnum itemCategory, string itemPrefix)
        {
            DateTime currentDate = DateTime.Now.AddMonths(MONTHS_START);
            DateTime endDate     = DateTime.Now.AddMonths(MONTHS_END);

            Random categoriesRandomizer = new Random();
            Random daysRandomizer       = new Random();
            Random amountRandomizer     = new Random();
            Random partnerRandomizer    = new Random();

            int nextItem   = 1;
            int minPartner = DbContext.Partners.Min(item => item.Id);
            int maxPartner = DbContext.Partners.Max(item => item.Id);
            List <Models.Categories> incomeCategories = DbContext.Categories
                                                        .Where(item => item.CategoryTypesId == (int)itemCategory).ToList();

            while (currentDate <= endDate)
            {
                currentDate = currentDate.AddDays(daysRandomizer.Next(20, 90));
                double amount     = amountRandomizer.NextDouble() * 1000 + 100;
                int    partnerId  = partnerRandomizer.Next(minPartner, maxPartner);
                int    categoryId = incomeCategories[categoriesRandomizer.Next(incomeCategories.Count - 1)].Id;

                Models.Item item = new Models.Item
                {
                    CategoriesId = categoryId,
                    DateAcquired = currentDate,
                    Value        = Convert.ToDecimal(Math.Round(amount, 2)),
                    Name         = itemPrefix + (nextItem++).ToString()
                };
                DbContext.Items.Add(item);
            }

            return(DbContext.SaveChanges());
        }
 public FileProperties(Models.Item item)
 {
     InitializeComponent();
     CurrentPath     = item.Path;
     CurrentFileInfo = new FileInfo(item.Path);
     LoadData();
 }
Beispiel #15
0
        void ComputeAverageRate(Models.Item item)
        {
            var rates = _context.ItemReviews.Where(r => r.ItemId == item.Id).Select(r => r.Note).ToArray();

            item.AverageRating = (decimal)rates.Sum() / rates.Count();
            _context.SaveChanges();
        }
Beispiel #16
0
 void ImportOtherItems(Models.Item item, IEnumerable <string> otherItems)
 {
     foreach (var otherItemData in otherItems)
     {
         var otherItem = _context.Items.SingleOrDefault();
     }
 }
Beispiel #17
0
 public IActionResult Create(Models.Item item)
 {
     item.User = _userManager.GetUserAsync(HttpContext.User).Result;
     _context.Items.Add(item);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
        private IEnumerable <Models.Item> GetItems(ItemSearch newsearch)
        {
            iDB2DataReader     readerITM = null;
            Item               item      = new Item();
            List <Models.Item> itemlist  = new List <Models.Item>();

            item.List(HttpContext.Session["SecurityKey"].ToString(), newsearch, ref readerITM);
            if (readerITM != null)
            {
                while (readerITM.Read())
                {
                    var    newitem = new Models.Item();
                    string formatYMD;
                    newitem.ItemID      = readerITM["ITMITM"].ToString();
                    newitem.Brand       = readerITM["ITMPG3"].ToString();
                    newitem.Size        = readerITM["ITMPG4"].ToString();
                    newitem.ItemDescEng = readerITM["ITMDSE"].ToString();

                    if (readerITM["ITMDT1"].ToString().Length == 5)
                    {
                        formatYMD = "0" + readerITM["ITMDT1"].ToString();
                    }
                    else
                    {
                        formatYMD = readerITM["ITMDT1"].ToString();
                    }
                    newitem.Date = DateTime.ParseExact(formatYMD, "yyMMdd", CultureInfo.InvariantCulture);
                    itemlist.Add(newitem);
                }
            }
            return(itemlist);
        }
        void ITransaccion.Execute()
        {
            // GenerateDocument();
            Models.Item item = getFromFile(file);
            if (item != null)
            {
                if (InsertItem(item))
                {
                    try {
                        if (File.Exists(this.HistPathOut + "\\OK_" + fname))
                        {
                            File.Delete(this.HistPathOut + "\\OK_" + fname);
                        }

                        File.Move(file, this.HistPathOut + "\\OK_" + fname);
                    } catch { }
                }
                else
                {
                    try {
                        if (File.Exists(this.HistPathOut + "\\ERR_" + fname))
                        {
                            File.Delete(this.HistPathOut + "\\ERR_" + fname);
                        }

                        File.Move(file, this.HistPathOut + "\\ERR_" + fname);
                    } catch { }
                }
            }
        }
 public ActionResult Eliminar(string key, Int64 Id)
 {
     var item = new Models.Item();
     item.Seleccionar(Id);
     item.Remove(key);
     return RedirectToAction("Detalles", "Item", new { Id = Id });
 }
Beispiel #21
0
 public FolderProperties(Models.Item folder)
 {
     InitializeComponent();
     CurrentFolder = new DirectoryInfo(folder.Path);
     InitializeData();
     LoadFolderSizeAsync();
 }
Beispiel #22
0
        public ActionResult Update(Models.Item item)
        {
            Data.Item persistentItem = Mapper.Map <Models.Item, Data.Item>(item);
            Itemizing.Update(persistentItem);

            return(Content(JsonConvert.SerializeObject(Mapper.Map <Data.Item, Models.Item>(persistentItem))));
        }
        public IActionResult Create(Models.Item item)
        {
            _context.Items.Add(item);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            int user_id = int.Parse(Session["user_id"].ToString());

            Models.User theUser = database.Users.SingleOrDefault(u => u.user_id == user_id);

            if (theUser == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                Models.Item theItem = database.Items.SingleOrDefault(i => i.item_id == id);
                theItem.item1 = collection["item1"];

                if (theItem.item1 == "")
                {
                    return(RedirectToAction("Edit"));
                }

                database.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #25
0
 // GET: Test
 public ActionResult Index()
 {
     ViewBag.abc = "kcskcskdc";
     Models.Item item = new Models.Item();
     item.getData();
     return(View(item));
 }
Beispiel #26
0
        public ActionResult Edit([Bind(Include = "id,title,desc,price_old,price,flag")] Models.Item item_tmp, FormCollection collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //Item
                    var item = db.Items.Find(item_tmp.id);
                    item.title         = item_tmp.title;
                    item.priceOld      = item_tmp.priceOld;
                    item.price         = item_tmp.price;
                    item.desc          = item_tmp.desc;
                    item.quantity      = item.quantity + long.Parse(collection["quantity_add"]);
                    item.quantityTotal = item.quantityTotal + long.Parse(collection["quantity_add"]);
                    //Images
                    var images = TM.IO.UploadImages(Request.Files, DirUpload.imagesProduct);
                    var tmp    = images.UploadFileString();
                    if (tmp != null)
                    {
                        item.images = tmp;
                    }
                    item.updatedBy       = Common.Auth.getUser().id.ToString();
                    item.updatedAt       = DateTime.Now;
                    db.Entry(item).State = EntityState.Modified;

                    //Group Item
                    var group_item = db.GroupItems.Where(d => d.itemId == item.id && d.flag > 0).FirstOrDefault();

                    if (group_item != null)
                    {
                        group_item.groupId   = Guid.Parse(collection["group_id"]);
                        db.Entry(item).State = EntityState.Modified;
                    }
                    else
                    {
                        group_item           = new Models.GroupItem();
                        group_item.id        = Guid.NewGuid();
                        group_item.appKey    = item.appKey;
                        group_item.groupId   = Guid.Parse(collection["group_id"]);
                        group_item.itemId    = item.id;
                        group_item.flag      = 1;
                        group_item.updatedBy = Common.Auth.getUser().id.ToString();
                        group_item.updatedAt = DateTime.Now;
                        db.GroupItems.Add(group_item);
                    }
                    db.SaveChanges();
                    this.success(TM.Common.Language.msgUpdateSucsess);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    this.danger(TM.Common.Language.msgError);
                }
            }
            catch (Exception ex)
            {
                this.danger(TM.Common.Language.msgUpdateError);
            }
            return(RedirectToAction("Edit"));
        }
        public ActionResult Create(FormCollection collection)
        {
            int user_id = int.Parse(Session["user_id"].ToString());

            Models.User theUser = database.Users.SingleOrDefault(u => u.user_id == user_id);

            if (theUser == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                Models.Item newItem = new Models.Item
                {
                    item1   = collection["item1"],
                    user_id = theUser.user_id
                };

                if (newItem.item1 == "")
                {
                    return(RedirectToAction("Create"));
                }

                database.Items.Add(newItem);
                database.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        // GET: Shopping/Delete/5
        public ActionResult Delete(int id)
        {
            int user_id = int.Parse(Session["user_id"].ToString());

            Models.User theUser = database.Users.SingleOrDefault(u => u.user_id == user_id);

            if (theUser == null)
            {
                return(RedirectToAction("Index", "Home"));
            }


            try
            {
                Models.Item theItem = database.Items.SingleOrDefault(i => i.item_id == id);
                database.Items.Remove(theItem);
                database.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #29
0
        public Bid Auction(Bid bidProduct)
        {
            var AuctionProduct = from p in db.AuctionProductTables select p;

            Models.Item myProduct = new Models.Item();

            var selectProduct = FetchByID(bidProduct.product.ProductID);

            foreach (var x in AuctionProduct)
            {
                x.ProductID          = bidProduct.product.ProductID;
                x.ProductName        = bidProduct.product.ProductName;
                x.ProductDescription = bidProduct.product.ProductDescription;
                x.BuyerName          = bidProduct.user.UName;
                x.ProductPrice       = bidProduct.product.ProductPrice;
                x.BidStartTime       = DateTime.Now;
            }
            foreach (var x in selectProduct)
            {
                myProduct.ProductName        = x.ProductName;
                myProduct.ProductDescription = x.ProductDescription;
                myProduct.ProductID          = x.ProductID;
                myProduct.TempWinner         = x.BuyerName;
                myProduct.ProductPrice       = (decimal)x.ProductPrice;
            }
            Bid bidUpate = new Bid(bidProduct.user, myProduct);

            return(bidUpate);
        }
        private bool ItemExist(Models.Item item)
        {
            bool res = false;

            SqlCommand cmd = new SqlCommand("SELECT COUNT([No]) FROM [Item] WHERE [No]=@No", new SqlConnection(this.StringConnection));

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@No", item.No);

            try
            {
                if (cmd.Connection.State != ConnectionState.Open)
                {
                    cmd.Connection.Open();
                }

                res = ((int)cmd.ExecuteScalar()) > 0;
            }catch (Exception ex)
            {
                IEvent e = new ErrorEvent("", "", "TransactionAddItemID::" + ex.Message);
                e.Publish();
            }
            finally
            {
                if (cmd.Connection.State == ConnectionState.Open)
                {
                    cmd.Connection.Close();
                }
            }

            return(res);
        }
        private Models.Item CreateItem(string name)
        {
            var items = Items();
            // get the max id
            int maxId = 1;
            if (items.Count != 0)
                maxId = (from i in items
                         select i.ID).Max();

            var newItem = new Models.Item { ID = maxId + 1, Name = name };

            items.Add(newItem);

            Session["Items"] = items;

            return newItem;
        }
        private int GenerateItems(CategoryTypesEnum itemCategory, string itemPrefix)
        {
            DateTime currentDate = DateTime.Now.AddMonths(MONTHS_START);
            DateTime endDate = DateTime.Now.AddMonths(MONTHS_END);

            Random categoriesRandomizer = new Random();
            Random daysRandomizer = new Random();
            Random amountRandomizer = new Random();
            Random partnerRandomizer = new Random();

            int nextItem = 1;
            int minPartner = DbContext.Partners.Min(item => item.Id);
            int maxPartner = DbContext.Partners.Max(item => item.Id);
            List<Models.Categories> incomeCategories = DbContext.Categories
                .Where(item => item.CategoryTypesId == (int)itemCategory).ToList();

            while (currentDate <= endDate)
            {
                currentDate = currentDate.AddDays(daysRandomizer.Next(20, 90));
                double amount = amountRandomizer.NextDouble() * 1000 + 100;
                int partnerId = partnerRandomizer.Next(minPartner, maxPartner);
                int categoryId = incomeCategories[categoriesRandomizer.Next(incomeCategories.Count - 1)].Id;

                Models.Item item = new Models.Item
                {
                    CategoriesId = categoryId,
                    DateAcquired = currentDate,
                    Value = Convert.ToDecimal(Math.Round(amount, 2)),
                    Name = itemPrefix + (nextItem++).ToString()
                };
                DbContext.Items.Add(item);
            }

            return DbContext.SaveChanges();
        }
Beispiel #33
0
 public ActionResult view(int id)
 {
     Models.Item it = new Models.Item();
     Models.Comment cm = new Models.Comment();
     ViewData["Message"] = it.getItem(id);
     ViewData["Comments"] = cm.getComment(id);
     return View("Item");
 }
Beispiel #34
0
        public string getCategory(int id_category)
        {
            if (id_category == null) return "";
            String result = "";
            SqlConnection Conn = null;
            Conn = new SqlConnection(@DataControll.StringConnect());
            string strSQL = "GetTovarfromcat";
            SqlCommand Cmd = new SqlCommand(strSQL, Conn);
            Cmd.CommandType = CommandType.StoredProcedure;
            Cmd.Parameters.Add("@id_cat", id_category);

            SqlParameter f0 = new SqlParameter("@id_cat", SqlDbType.Int);

            Conn.Open();
            SqlDataReader myReader = Cmd.ExecuteReader();
            int id_tovar = 0;
            while (myReader.Read())
            {

                id_tovar = myReader.GetInt32(0);
                Models.Item it = new Models.Item();
                result = result + " " + it.getItemcat(id_tovar);

            }

            Conn.Close();
            return  result;
        }
Beispiel #35
0
 //вывод отдельно взятого товара
 public String getItem(int id)
 {
     try
     {
         if (id == null) return "";
         Models.Item it = new Models.Item();
         Models.Comment cm = new Models.Comment();
         String result = it.getItem(id);
         result = result + "<br>" + cm.getComment(id);
         return result;
     }
     catch
     {
         return "Товар не найден!";
     }
 }
Beispiel #36
0
        public ActionResult view(int id,Models.Comment  cm)
        {
            if (cm.text != "" & Session["user_id"]!="")
              {
                  cm.doAddComment(Convert.ToInt32(Session["user_id"]), id, cm.text);
              }
              Models.Item it = new Models.Item();

              ViewData["Message"] = it.getItem(id);
              ViewData["Comments"] = cm.getComment(id);
              return View("Item");
        }