public ActionResult Upload() { var model = new VehicleSpectModel(); model.MainMenu = _mainMenu; model.CurrentLogin = CurrentUser; return(View(model)); }
// // GET: /VehicleSpect/ public ActionResult Index() { var data = _VehicleSpectBLL.GetVehicleSpect(); var model = new VehicleSpectModel(); model.Details = Mapper.Map <List <VehicleSpectItem> >(data); model.MainMenu = _mainMenu; model.CurrentLogin = CurrentUser; model.CurrentPageAccess = CurrentPageAccess; if (CurrentUser.UserRole == Enums.UserRole.Viewer) { model.IsShowNewButton = false; model.IsNotViewer = false; } else { model.IsShowNewButton = true; model.IsNotViewer = true; } return(View(model)); }
public ActionResult Upload(VehicleSpectModel Model) { if (ModelState.IsValid) { foreach (VehicleSpectItem data in Model.Details) { try { string imagename = System.IO.Path.GetFileName(data.Image); //Stream imageStream = System.IO.File.Open(data.Image, FileMode.Open); //byte[] imageBytes; //using (BinaryReader br = new BinaryReader(imageStream)) //{ // imageBytes = br.ReadBytes(500000); // br.Close(); //} //System.IO.File.WriteAllBytes(Server.MapPath("~/files_upload/" + imagename), imageBytes); //data.Image = imagename; data.CreatedDate = DateTime.Now; data.CreatedBy = CurrentUser.USERNAME; data.ModifiedDate = null; var dto = Mapper.Map <VehicleSpectDto>(data); _VehicleSpectBLL.Save(dto); AddMessageInfo(Constans.SubmitMessage.Saved, Enums.MessageInfoType.Success); } catch (Exception exception) { Model.MainMenu = _mainMenu; Model.CurrentLogin = CurrentUser; Model.ErrorMessage = exception.Message; AddMessageInfo(exception.Message, Enums.MessageInfoType.Error); return(View(Model)); } } } return(RedirectToAction("Index", "MstVehicleSpect")); }