Ejemplo n.º 1
0
        //Update topic
        public bool UpdateTopic(TopCreateViewModel model)
        {
            Topic updateTopic = topicUnitOfWork.GetByID(model.TopicID);

            updateTopic.WriterID       = model.WriterID;
            updateTopic.Title          = model.Title;
            updateTopic.Topic_content  = model.Topic_content;
            updateTopic.CreatedDate    = model.CreatedDate;
            updateTopic.UpdatedDate    = model.UpdatedDate;
            updateTopic.UpdatedStaffID = model.UpdateStaffID;
            updateTopic.IsApproved     = model.IsApprove; //Must be converted into null Variable;
            updateTopic.IsDeleted      = model.IsDelete;
            updateTopic.ImageUrl       = model.ImageUrl;
            updateTopic.IsUpdated      = true;

            return(topicUnitOfWork.Update(updateTopic));
        }
Ejemplo n.º 2
0
        //Create new topic
        public bool CreateTopic(TopCreateViewModel model)
        {
            Topic newTopic = new Topic();

            newTopic.WriterID       = model.WriterID;
            newTopic.Title          = model.Title;
            newTopic.Topic_content  = model.Topic_content;
            newTopic.CreatedDate    = DateTime.Now;
            newTopic.UpdatedDate    = null;
            newTopic.UpdatedStaffID = null;
            newTopic.IsApproved     = null; //Must be converted into null Variable;
            newTopic.IsDeleted      = false;
            newTopic.ImageUrl       = model.ImageUrl;
            newTopic.IsUpdated      = false;

            return(topicUnitOfWork.Create(newTopic));
        }
Ejemplo n.º 3
0
        public ActionResult Create(TopCreateViewModel model, HttpPostedFileBase file)
        {
            //Get user ID here
            model.WriterID = topicUnitOfWork.AspNetUserRepository.Get(s => s.UserName == User.Identity.Name).FirstOrDefault().Id;
            model.CreatedDate = DateTime.Now;

            //File uploade code
            if (file != null && file.ContentLength > 0)
            {
                string path = "/Content/img/TopicImg";
                // extract only the fielname
                model.ImageUrl = Path.GetFileName(file.FileName);
                // store the file inside ~/App_Data/uploads folder
                model.ImageUrl = Path.Combine(Server.MapPath(path), model.ImageUrl);
                file.SaveAs(model.ImageUrl);
                model.ImageUrl = path + "/" + Path.GetFileName(file.FileName);
            }

            if (functionModel.CreateTopic(model))
            {
                return RedirectToAction("OwnList");
            }
            return View(model);
        }
Ejemplo n.º 4
0
        //Update topic
        public bool UpdateTopic(TopCreateViewModel model)
        {
            Topic updateTopic = topicUnitOfWork.GetByID(model.TopicID);
            updateTopic.WriterID = model.WriterID;
            updateTopic.Title = model.Title;
            updateTopic.Topic_content = model.Topic_content;
            updateTopic.CreatedDate = model.CreatedDate;
            updateTopic.UpdatedDate = model.UpdatedDate;
            updateTopic.UpdatedStaffID = model.UpdateStaffID;
            updateTopic.IsApproved = model.IsApprove; //Must be converted into null Variable;
            updateTopic.IsDeleted = model.IsDelete;
            updateTopic.ImageUrl = model.ImageUrl;
            updateTopic.IsUpdated = true;

            return topicUnitOfWork.Update(updateTopic);
        }
Ejemplo n.º 5
0
        //Create new topic
        public bool CreateTopic(TopCreateViewModel model)
        {
            Topic newTopic = new Topic();
            newTopic.WriterID = model.WriterID;
            newTopic.Title = model.Title;
            newTopic.Topic_content = model.Topic_content;
            newTopic.CreatedDate = DateTime.Now;
            newTopic.UpdatedDate = null;
            newTopic.UpdatedStaffID = null;
            newTopic.IsApproved = null; //Must be converted into null Variable;
            newTopic.IsDeleted = false;
            newTopic.ImageUrl = model.ImageUrl;
            newTopic.IsUpdated = false;

            return topicUnitOfWork.Create(newTopic);
        }
Ejemplo n.º 6
0
 public ActionResult Create()
 {
     TopCreateViewModel model = new TopCreateViewModel();
     return View(model);
 }