private void SaveImages(List <ViewDataUploadFilesResult> resultList, FileControllerIndexViewModel model) { var entityTypeId = model.Entitytype.AsInt(); var Entitytype = (EntityType)entityTypeId; foreach (var item in resultList) { var filename = item.name; switch (Entitytype) { case EntityType.None: break; case EntityType.Person: GetPersonnelPictureService().Insert(new Entities.Models.PersonnelPicture { CompanyId = model.CompanyId, PersonnelId = model.EntityId, Extension = Path.GetExtension(filename), //Id = model.ImageId.AsInt(), Name = Path.GetFileNameWithoutExtension(filename), CreatedOn = DateTime.UtcNow, CreatedBy = User.Identity.GetUserId() }); break; case EntityType.Company: GetCompanyPictureService().Insert(new Entities.Models.CompanyPicture { CompanyId = model.CompanyId, Name = Path.GetFileNameWithoutExtension(filename), Extension = Path.GetExtension(filename), //Id = model.ImageId.AsInt(), CreatedOn = DateTime.UtcNow, CreatedBy = User.Identity.GetUserId() }); break; case EntityType.ZetaCodeNormalIplik: GetZetaCodeNormalIplikPictureService().Insert(new Entities.Models.ZetaCodeNormalIplikPicture { CompanyId = model.CompanyId, ZetaCodeNormalIplikId = model.EntityId.AsInt(), Name = Path.GetFileNameWithoutExtension(filename), Extension = Path.GetExtension(filename), //Id = model.ImageId.AsInt(), CreatedOn = DateTime.UtcNow, CreatedBy = User.Identity.GetUserId() }); break; default: break; } } UnitOfWorkAsync.SaveChanges(); }
//public ActionResult Show(string entitytype) //{ // JsonFiles ListOfFiles = filesHelper.GetFileList(entitytype); // var model = new FilesViewModel() // { // Files = ListOfFiles.files // }; // return View(model); //} public ActionResult Edit(FileControllerIndexViewModel model) { if (model.EntityId.IsNullOrWhiteSpace()) { Failure = "Gerekli Bilgilere Ulaşılamadı"; return(RedirectToLocal(model.ReturnUrl)); } return(View(model)); }
public ActionResult Index(FileControllerIndexViewModel model) { if (model.EntityId.IsNullOrWhiteSpace()) { Failure = "Gerekli Bilgilere Ulaşılamadı"; return(RedirectToLocal(model.ReturnUrl)); } //var IpAddress = HttpContext.Request.UserHostAddress; //var UserAgent = HttpContext.Request.UserAgent; //var PathAndQuery = HttpContext.Request.Url == null ? "" : HttpContext.Request.Url.PathAndQuery; //var HttpReferer = HttpContext.Request.UrlReferrer == null ? "" : HttpContext.Request.UrlReferrer.PathAndQuery; //SetImageData(model); return(View(model)); }
public ActionResult Upload(FileControllerIndexViewModel model) { var resultList = new List <ViewDataUploadFilesResult>(); var CurrentContext = HttpContext; filesHelper.UploadAndShowResults(CurrentContext, resultList, model.Entitytype); JsonFiles files = new JsonFiles(resultList); bool isEmpty = !resultList.Any(); if (isEmpty) { return(Json("Error ")); } else { SaveImages(resultList, model); return(Json(files)); } }