private UserPost ConvertToDM(UserPostBM model) { if (model == null) return null; else return new UserPost { Id = model.Id, UserId = model.UserId, Subject = model.Subject, Post = model.Post, FilePath = model.FilePath, FileUrl = model.FileUrl, PostType=model.PostType, CreatedBy = model.CreatedBy, CreationDate = model.CreationDate, ModifiedBy = model.ModifiedBy, ModificationDate = model.ModificationDate }; }
public void Create(UserPostBM model) { uow.UserPostRepository.Add(ConvertToDM(model)); uow.Save(); }
public void Update(UserPostBM model) { uow.UserPostRepository.Update(ConvertToDM(model)); uow.Save(); }
public ActionResult NewPost(PostCommentModel Model, HttpPostedFileBase file, FormCollection collection) { UserBM CurrentUser = SessionManager.InstanceCreator.Get<UserBM>(SessionKey.User); string type = collection["type"].ToString(); if (CurrentUser != null) { UserPostBM UserPostBM = new UserPostBM(); UserPostBM.Post = Model.UserPost.Post; UserPostBM.Subject = Model.UserPost.Subject; UserPostBM.FileUrl=Model.UserPost.FileUrl; if (file != null) { string ImageName = System.IO.Path.GetFileName(file.FileName); string physicalPath = Server.MapPath("~/Images/" + ImageName); file.SaveAs(physicalPath); UserPostBM.FilePath = "/Images/" + ImageName; } UserPostBM.UserId = CurrentUser.Id; if (!string.IsNullOrEmpty(type)) UserPostBM.PostType = Convert.ToInt32(type); UserPostBM.CreatedBy = CurrentUser.Id; UserPostBM.CreationDate = DateTime.Now; UserPostBL.Create(UserPostBM); TempData["Success"] = "Record saved Successfully."; } else { TempData["Error"] = "Please Login."; } return RedirectToAction("UserPost"); }