public ActionResult Create(PackageModel model) { try { if (ModelState.IsValid) { CaculateModel(model); string msg = ""; string generatedfileName = SaveFile(inputFileFieldName, out msg); model.File = generatedfileName; if (string.IsNullOrWhiteSpace(generatedfileName)) { ModelState.AddModelError(inputFileFieldName, msg); return View(model); } PackageBusiness b = new PackageBusiness(); b.AddPackage(ObjectCopier.Copy<Package>(model)); } return RedirectToAction("Index"); } catch { return View(); } }
private void CaculateModel(PackageModel model) { model.CreateTime = DateTime.Now; model.Enable = true; model.Fingerprint = HashHelper.ComputeHashString(HashHelper.HashName.MD5, Request.Files[inputFileFieldName].InputStream); model.PackageName = Request.Files[inputFileFieldName].FileName; model.PackageSize = Request.Files[inputFileFieldName].ContentLength; model.Verified = false; }