예제 #1
0
        public ActionResult Upload(FileUploadBindingModel form, HttpPostedFileBase file)
        {
            var _name = form.Location.Substring(form.Location.LastIndexOf('/') + 1);
            var _location = form.Location.LastIndexOf('/') >= 0 ? form.Location.Substring(0, form.Location.LastIndexOf('/')) : string.Empty;

            var container = _uow.Documents.FilterBy(d => d.Location == _location && d.Name == _name).FirstOrDefault();

            string path = container == null ?
                            string.Format("{0}/{1}/{2}", Server.MapPath(_config.BaseUrl), _user.User.Email, file.FileName) :
                            string.Format("{0}/{1}", container.Path, file.FileName);
            // physical
            if (file != null)
                file.SaveAs(path);

            // logical
            var document = Doc.CreateFile(string.IsNullOrEmpty(form.Name) ? file.FileName : form.Name, form.Description, false,
                                    new FileInfo(path).FullName, container, _user.User);
            document.ContentLength = file.ContentLength;
            document.ContentType = MimeMapping.GetMimeMapping(file.FileName);
            document.Location = form.Location;

            _uow.Documents.Add(document);
            _uow.Save();

            return RedirectToAction<DocumentController>(c => c.Browse(document.Location));
        }
예제 #2
0
        public ActionResult Upload(string location)
        {
            var vm = new FileUploadBindingModel(location);
            return View(vm);

        }