コード例 #1
0
        public ActionResult AddDocument(Document model,HttpPostedFileBase uploadfile)
        {
            FillLanguagesList();

            if (ModelState.IsValid)
            {

                if (uploadfile != null && uploadfile.ContentLength > 0)
                {
                    Random random = new Random();
                    int rand = random.Next(1000, 99999999);
                    uploadfile.SaveAs(Server.MapPath("/Content/images/documents/"+ Utility.SetPagePlug(model.Name) + "_" + rand + Path.GetExtension(uploadfile.FileName)));
                    model.DocumentFile = "/Content/images/documents/" + Utility.SetPagePlug(model.Name) + "_" + rand + Path.GetExtension(uploadfile.FileName);
                }
                else
                {
                    model.DocumentFile = "Dosya Yok";
                }
                ModelState.Clear();
                ViewBag.ProcessMessage = DocumentManager.AddDocument(model);
            }
            return View();
        }
コード例 #2
0
        public ActionResult EditDocument(Document model, HttpPostedFileBase uploadfile)
        {
            FillLanguagesList();

            if (ModelState.IsValid)
            {

                if (uploadfile != null && uploadfile.ContentLength > 0)
                {
                    Random random = new Random();
                    int rand = random.Next(1000, 99999999);
                    uploadfile.SaveAs(Server.MapPath("/Content/images/documents/" + Utility.SetPagePlug(model.Name) + "_" + rand + Path.GetExtension(uploadfile.FileName)));
                    model.DocumentFile = "/Content/images/documents/" + Utility.SetPagePlug(model.Name) + "_" + rand + Path.GetExtension(uploadfile.FileName);
                }


                if (RouteData.Values["id"] != null)
                {
                    int nid = 0;
                    bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                    if (isnumber)
                    {
                        model.DocumentId = nid;
                        ViewBag.ProcessMessage = DocumentManager.EditDocument(model);
                        return View(model);
                    }
                    else
                    {
                        ViewBag.ProcessMessage = false;
                        return View(model);
                    }
                }
                else return View();

              
            }
            else
                return View();
        }
コード例 #3
0
        public static bool EditDocument(Document data)
        {
            using (DeneysanContext db = new DeneysanContext())
            {
                try
                {
                    Document record = db.Document.Where(d => d.DocumentId == data.DocumentId && d.Deleted == false).SingleOrDefault();
                    if (record != null)
                    {
                        record.Name = data.Name;
                        record.Language = data.Language;
                        record.DocumentGroupId = data.DocumentGroupId;
                        if (!string.IsNullOrEmpty(data.DocumentFile))
                        {
                            record.DocumentFile = data.DocumentFile;
                        }
                        record.TimeUpdated = DateTime.Now;

                        db.SaveChanges();

                        LogtrackManager logkeeper = new LogtrackManager();
                        logkeeper.LogDate = DateTime.Now;
                        logkeeper.LogProcess = EnumLogType.Dokuman.ToString();
                        logkeeper.Message = LogMessages.DocumentEdited;
                        logkeeper.User = HttpContext.Current.User.Identity.Name;
                        logkeeper.Data = record.Name;
                        logkeeper.AddInfoLog(logger);


                        return true;
                    }
                    else
                        return false;
                  
                   

                }
                catch (Exception ex)
                {
                    return false;
                }
            }

        }
コード例 #4
0
        public static bool AddDocument(Document record)
        {
            using (DeneysanContext db = new DeneysanContext())
            {
                try
                {
                   
                    record.TimeCreated = DateTime.Now;
                    record.Deleted = false;
                    
                    record.Online = true;
                    record.SortNumber = 9999;
                    db.Document.Add(record);
                    db.SaveChanges();

                    LogtrackManager logkeeper = new LogtrackManager();
                    logkeeper.LogDate = DateTime.Now;
                    logkeeper.LogProcess = EnumLogType.Dokuman.ToString();
                    logkeeper.Message = LogMessages.DocumentAdded;
                    logkeeper.User = HttpContext.Current.User.Identity.Name;
                    logkeeper.Data = record.Name;
                    logkeeper.AddInfoLog(logger);


                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }
            }

        }