Exemplo n.º 1
0
        private MasterFilePath ConvertToDM(MasterFilePathBM model)
        {
            return new MasterFilePath
            {

                Id=model.Id,

                ModuleId=model.ModuleId,

                FilePath=model.FilePath
            };
        }
        public ActionResult NewTechnology(LatestTutorialsModel Model,FormCollection collection, List<HttpPostedFileBase> file)
        {
            UserBM CurrentUser = SessionManager.InstanceCreator.Get<UserBM>(SessionKey.User);

            if (CurrentUser != null)
            {
                string url = collection["url"].ToString();
                string[] strUrlArray = new string[] { };
                if (!string.IsNullOrEmpty(url))
                    strUrlArray = url.Split(',');
                //  string filepaths = collection["file"].ToString();
                LatestTutorialsBM latestTutorialsBM = new LatestTutorialsBM();
                latestTutorialsBM.CommunityId = Model.LatestTutorialsBM.CommunityId;
                latestTutorialsBM.SubCommunityId = Model.LatestTutorialsBM.SubCommunityId;
                latestTutorialsBM.Tag = Model.LatestTutorialsBM.Tag;
                latestTutorialsBM.Subject = Model.LatestTutorialsBM.Subject;
                latestTutorialsBM.Topic = Model.LatestTutorialsBM.Topic;
                latestTutorialsBM.EarnPoint = 1;
                // latestTechnologyBM.Content = Model.latestTechnologyBM.Content;
                // latestTechnologyBM.Url = Model.latestTechnologyBM.Url;
                //latestTechnologyBM.VideoUrl = Model.latestTechnologyBM.VideoUrl;
                // latestTechnologyBM.FilePath = Model.latestTechnologyBM.FilePath;
                latestTutorialsBM.UserId = CurrentUser.Id;
                latestTutorialsBM.IsActive = true;

              int Id=  LatestTutorialsBL.Create(latestTutorialsBM);

              #region MultipleUrl
              foreach (var strUrl in strUrlArray)
              {
                  MasterUrlBL masterUrlBL = new MasterUrlBL();
                  MasterUrlBM masterUrlBM = new MasterUrlBM();
                  masterUrlBM.ModuleId = Id;
                  masterUrlBM.Url = strUrl;
                  masterUrlBL.Create(masterUrlBM);
              }
              #endregion
              #region MultipleFile
              foreach (var fileInstance in file)
              {
                  if (fileInstance != null)
                  {
                      string ImageName = System.IO.Path.GetFileName(fileInstance.FileName);
                      if (!Directory.Exists(Server.MapPath("~/Images/TechnologyDocument")))
                      {
                          Directory.CreateDirectory(Server.MapPath("~/Images/TechnologyDocument"));
                      }
                      string physicalPath = Server.MapPath("~/Images/TechnologyDocument/" + ImageName);
                      fileInstance.SaveAs(physicalPath);
                      //     latestTechnologyBM.FilePath = "~/Images/TechnologyDocument/" + ImageName;

                      MasterFilePathBL masterFilePathBL = new MasterFilePathBL();
                      MasterFilePathBM masterFilePathBM = new MasterFilePathBM();
                      masterFilePathBM.ModuleId = Id;
                      masterFilePathBM.FilePath = "~/Images/TechnologyDocument/" + ImageName; ;
                      masterFilePathBL.Create(masterFilePathBM);
                  }
              }
              #endregion
                TempData["Success"] = "Record Saved Successfully.";
            }
            else
            {
                TempData["Error"] = "Please Login.";
            }
            return RedirectToAction("Index");
        }
Exemplo n.º 3
0
 public void Update(MasterFilePathBM model)
 {
     uow.MasterFilePathRepository.Update(ConvertToDM(model));
     uow.Save();
 }