Exemplo n.º 1
0
 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
     };
 }
Exemplo n.º 2
0
 public void Create(UserPostBM model)
 {
     uow.UserPostRepository.Add(ConvertToDM(model));
     uow.Save();
 }
Exemplo n.º 3
0
 public void Update(UserPostBM model)
 {
     uow.UserPostRepository.Update(ConvertToDM(model));
     uow.Save();
 }
Exemplo n.º 4
0
        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");
        }