public ActionResult DeleteConfirmed(int id)
        {
            CatalogueEntry catalogueEntry = db.CatalogueEntries.Find(id);

            db.CatalogueEntries.Remove(catalogueEntry);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public CatalogueEntry SaveEntry(CatalogueEntry c)
        {
            CatalogueDAL catDal = new CatalogueDAL();

            catDal.CatalogueEntries.Add(c);
            catDal.SaveChanges();
            return(c);
        }
 public ActionResult Edit([Bind(Include = "CatalogueEntryID,Timing,Title,Repeat,TVDate,Dow,BegTime,Sti,Dm,Dr,ProducerCode,SellerCode")] CatalogueEntry catalogueEntry)
 {
     if (ModelState.IsValid)
     {
         db.Entry(catalogueEntry).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(catalogueEntry));
 }
        // GET: CatalogueEntries/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CatalogueEntry catalogueEntry = db.CatalogueEntries.Find(id);

            if (catalogueEntry == null)
            {
                return(HttpNotFound());
            }
            return(View(catalogueEntry));
        }
Пример #5
0
        public EntryEditModel(CatalogueEntry a)
        {
            if (a == null)
            {
                return;
            }
            UniqueId     = a.UniqueId;
            Name         = a.Name;
            ValidFrom    = a.Valid.From;
            ValidTo      = a.Valid.To;
            ProductTypes = new List <ProductTypeModel>();

            foreach (var type in a.ProductTypes)
            {
                ProductTypes.Add(new ProductTypeModel(type));
            }
        }
        public ActionResult CreateEntry([Bind(Include = "UniqueId,Name,ValidFrom, ValidTo")] EntryEditModel p)
        {
            if (!ModelState.IsValid)
            {
                return(View("CreateEntry", p));
            }
            var entry = new CatalogueEntry()
            {
                UniqueId    = Guid.NewGuid().ToString(),
                Name        = p.Name,
                CatalogueId = productCatalogue.UniqueId,
                Valid       = new Period()
                {
                    From = p.ValidFrom, To = p.ValidTo
                }
            };
            var ebl = new EntryBusinessLayer();

            ebl.SaveEntry(entry);
            CatalogueEntries.Instance.Add(entry);
            //ebl.UploadEntries(CatalogueEntries.Instance.ToList());
            return(RedirectToAction("Index"));
        }
 public void CleanUpTest()
 {
     k = null;
 }
 public void InitializeTest()
 {
     k = new CatalogueEntry();
 }
        public ActionResult ImportCat()
        {
            //db.CatalogueEntries.RemoveRange(db.CatalogueEntries);

            List <CatalogueEntry> ces = new List <CatalogueEntry>();

            int i = 0;

            try
            {
                i = db.CatalogueEntries.Count();
            }
            catch
            {
            }
            using (var reader = new StreamReader(Path.Combine(HttpContext.ApplicationInstance.Server.MapPath("~/Content"), "cat20180130.csv"), Encoding.UTF8))
            {
                reader.ReadLine();
                //List<string> listA = new List<string>();
                //List<string> listB = new List<string>();
                while (!reader.EndOfStream)
                {
                    if (i > 0)
                    {
                        CatalogueEntry curCE  = new CatalogueEntry();
                        var            line   = reader.ReadLine();
                        var            values = line.Split('\t');
                        if (values.Length > 10)
                        {
                            try
                            {
                                curCE.CatalogueEntryID = Convert.ToInt32(values[0]);
                            }
                            catch
                            {
                            }
                            try
                            {
                                curCE.Timing = Convert.ToDateTime(values[1]);
                            }
                            catch
                            {
                                curCE.Timing = DateTime.Parse("01-01-2001");
                            }
                            curCE.Title = values[2];
                            try
                            {
                                curCE.TVDate = Convert.ToDateTime(values[3]);
                            }
                            catch { }

                            try { curCE.Dow = Convert.ToInt16(values[4]); } catch { }
                            try
                            {
                                curCE.BegTime = Convert.ToDateTime(values[5]);
                            }
                            catch
                            {
                                curCE.BegTime = DateTime.Parse("01-01-2001");
                            }
                            try
                            {
                                curCE.Sti = Convert.ToSingle(values[6].Replace(".", ","));
                            }
                            catch { }
                            try
                            {
                                curCE.Dm = Convert.ToSingle(values[7].Replace(".", ","));
                            }
                            catch { }
                            try
                            {
                                curCE.Dr = Convert.ToSingle(values[8].Replace(".", ","));
                            }
                            catch { }
                            try
                            {
                                curCE.ProducerCode = Convert.ToInt16(values[9]);
                            }
                            catch { }
                            try
                            { curCE.SellerCode = Convert.ToInt16(values[10]); }
                            catch { }
                            if (i > curCE.CatalogueEntryID)
                            {
                                db.CatalogueEntries.Add(curCE);
                                db.SaveChanges();
                            }
                            //ces.Add(curCE);


                            //listA.Add(values[0]);
                            //listB.Add(values[1]);
                        }
                    }
                    i = i + 1;
                }
            }
            //db.SaveChanges();
            //db.CatalogueEntries.AddRange(ces);

            return(View("Index"));
        }