protected void ExtraModelToEntity(Autos entity, AutosModel model, ActionTypes actionType) { if (actionType == ActionTypes.Add) { entity.AutoMaterialRsps = new List <AutoMaterialRsp>(); var materialManager = GlobalConfiguration.Configuration.DependencyResolver.GetService <IMaterialsManager>(); foreach (var material in materialManager.GetEntities().Where(o => !o.DeleteDate.HasValue && o.IsForAuto).ToList()) { entity.AutoMaterialRsps.Add(new AutoMaterialRsp() { Amount = 0, Autos = entity, MaterialId = material.Id }); } entity.AutoInstrumentRsps = new List <AutoInstrumentRsp>(); var instrumentManager = GlobalConfiguration.Configuration.DependencyResolver.GetService <IInstrumentsManager>(); foreach (var instrument in instrumentManager.GetEntities().Where(o => !o.DeleteDate.HasValue && o.IsForAuto).ToList()) { entity.AutoInstrumentRsps.Add(new AutoInstrumentRsp() { Amount = 0, Autos = entity, InstrumentId = instrument.Id }); } } }
public void Autos(AutosModel model, List <HttpPostedFileBase> fileUpload) { DataTable personalInfoDT = objUserManager.getPersonalInformation(User.Identity.Name); string updatedFileName = null; foreach (HttpPostedFileBase file in fileUpload) { if (file != null && Array.Exists(model.images.Split(','), s => s.Equals(file.FileName))) { var filename = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Images/DBImages/"), filename); file.SaveAs(path); updatedFileName = updatedFileName + User.Identity.Name + filename + ","; } } // No file Found if (fileUpload.Count == 1) { model.images = "../../Images/DBImages/notfound.jpg"; } model.images = updatedFileName.TrimEnd(','); model.postedBy = User.Identity.Name; model.category = "Autos"; model.phone = personalInfoDT.Rows[0]["phoneNo"].ToString(); model.email = personalInfoDT.Rows[0]["email"].ToString(); model.postedDate = DateTime.Now.ToString(); model.latitude = personalInfoDT.Rows[0]["latitude"].ToString(); model.altitude = personalInfoDT.Rows[0]["longitude"].ToString(); model.unCommonAttributes = null; }