Esempio n. 1
0
        public ActionResult Edit(TextTypeItem textItems, HttpPostedFileBase fileupload)
        {
            if (ModelState.IsValid)
            {
                #region Upload and resize image if needed
                string newFilenameUrl = string.Empty;

                if (fileupload != null)
                {
                    string filename    = Path.GetFileName(fileupload.FileName);
                    string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                         + Path.GetExtension(filename);
                    newFilenameUrl = "/Uploads/Text/" + newFilename;
                    string physicalFilename = Server.MapPath(newFilenameUrl);
                    fileupload.SaveAs(physicalFilename);
                    textItems.ImageUrl = newFilenameUrl;
                }

                #endregion
                textItems.LastModifiedDate = DateTime.Now;
                textItems.IsDeleted        = false;
                db.Entry(textItems).State  = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { @id = textItems.TextTypeId }));
            }
            return(View(textItems));
        }
Esempio n. 2
0
        public TextTypeItem ReturnFooter()
        {
            Guid         footerAboutId = new Guid("e3e502a5-9348-4d95-931e-18eee54c055f");
            TextTypeItem textTypeItem  = db.TextTypeItems.Find(footerAboutId);

            return(textTypeItem);
        }
        public ActionResult Create(TextTypeItem textTypeItem, Guid id, HttpPostedFileBase fileUpload)
        {
            if (ModelState.IsValid)
            {
                #region Upload and resize image if needed
                string newFilenameUrl = string.Empty;
                if (fileUpload != null)
                {
                    string filename    = Path.GetFileName(fileUpload.FileName);
                    string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty)
                                         + Path.GetExtension(filename);

                    newFilenameUrl = "/Uploads/Text/" + newFilename;
                    string physicalFilename = Server.MapPath(newFilenameUrl);

                    fileUpload.SaveAs(physicalFilename);

                    textTypeItem.ImageUrl = newFilenameUrl;
                }
                #endregion
                textTypeItem.IsDelete   = false;
                textTypeItem.SubmitDate = DateTime.Now;
                textTypeItem.TextTypeId = id;
                textTypeItem.Id         = Guid.NewGuid();
                db.TextTypeItems.Add(textTypeItem);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = id }));
            }


            return(View(textTypeItem));
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            TextTypeItem textTypeItem = db.TextTypeItems.Find(id);

            textTypeItem.IsDelete   = true;
            textTypeItem.DeleteDate = DateTime.Now;

            db.SaveChanges();
            return(RedirectToAction("Index", new { id = textTypeItem.TextTypeId }));
        }
Esempio n. 5
0
        // GET: TextItems/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TextTypeItem textItems = db.TextTypeItems.Find(id);

            if (textItems == null)
            {
                return(HttpNotFound());
            }
            ViewBag.fk = textItems.TextTypeId;
            return(View(textItems));
        }
        // GET: TextTypeItems/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TextTypeItem textTypeItem = db.TextTypeItems.Find(id);

            if (textTypeItem == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id = textTypeItem.TextTypeId;
            return(View(textTypeItem));
        }
Esempio n. 7
0
        public ActionResult Create(TextTypeItem textTypeItem, Guid id)
        {
            if (ModelState.IsValid)
            {
                textTypeItem.IsDeleted    = false;
                textTypeItem.CreationDate = DateTime.Now;

                textTypeItem.Id         = Guid.NewGuid();
                textTypeItem.TextTypeId = id;
                db.TextTypeItems.Add(textTypeItem);
                db.SaveChanges();
                return(RedirectToAction("Index", new { @id = textTypeItem.TextTypeId }));
            }
            ViewBag.fk         = id;
            ViewBag.TextTypeId = new SelectList(db.TextTypes.Where(current => current.IsDeleted == false && current.IsActive == true).ToList(), "Id", "Title");
            return(View(textTypeItem));
        }