Ejemplo n.º 1
0
        public ActionResult UpdateExercise(int id)
        {
            StringBuilder traceLog = new StringBuilder();

            if (Login.IsSessionExpire(Convert.ToString(HttpContext.Session[ConstantHelper.constLoginUserName])) ||
                Convert.ToString(HttpContext.Session[ConstantHelper.constUserType]) != ConstantHelper.constLoginadmin)
            {
                return(RedirectToAction(ConstantHelper.constLogin, ConstantHelper.constLogin));
            }
            try
            {
                if (id > 0)
                {
                    traceLog.AppendLine("Start: UpdateExercise() in Exercise controller");
                    ViewExerciseVM objViewExerciseVM = ExerciseBL.UpdateExercise(id);
                    return(View(objViewExerciseVM));
                }
                return(View());
            }
            catch (Exception ex)
            {
                LogManager.LogManagerInstance.WriteErrorLog(ex);
                /*return view to error page*/
                return(View());
            }
            finally
            {
                traceLog.AppendLine("UpdateTrainer end() : --- " + DateTime.Now.ToLongDateString());
                LogManager.LogManagerInstance.WriteTraceLog(traceLog);
            }
        }
Ejemplo n.º 2
0
        public ActionResult UpdateExercise(ViewExerciseVM updateExecise)
        {
            StringBuilder traceLog = new StringBuilder();

            if (Login.IsSessionExpire(Convert.ToString(HttpContext.Session[ConstantHelper.constLoginUserName])) ||
                Convert.ToString(HttpContext.Session[ConstantHelper.constUserType]) != ConstantHelper.constLoginadmin)
            {
                return(RedirectToAction(ConstantHelper.constLogin, ConstantHelper.constLogin));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    traceLog.AppendLine("Start: UpdateExercise() in Exercise controller");
                    string sproutId = ExerciseBL.UpdateExercise(updateExecise);
                    TempData["AlertMessage"] = Message.UpdateMessage;
                    var httpRequest = System.Web.HttpContext.Current.Request;
                    if (httpRequest.Files.Count > 0)
                    {
                        string sPath = "";
                        sPath = Server.MapPath("~/Temp/");
                        for (int i = 0; i < httpRequest.Files.Count; i++)
                        {
                            var    fileDoc    = httpRequest.Files[i];
                            string newVideoId = Path.GetFileName(fileDoc.FileName);
                            if (!System.IO.File.Exists(newVideoId))
                            {
                                fileDoc.SaveAs(sPath + newVideoId);
                                if (string.IsNullOrEmpty(sproutId))
                                {
                                    UploadExecelToFitcom(sPath + newVideoId);
                                }
                                else
                                {
                                    UpdateExeciseVideoToFitcom(sPath + newVideoId, updateExecise.ExerciseId, sproutId);
                                }
                            }
                        }
                    }
                    return(RedirectToAction(HttpContext.Session[Message.PreviousUrl].ToString()));
                }
                else
                {
                    return(View(updateExecise));
                }
            }
            catch (Exception ex)
            {
                LogManager.LogManagerInstance.WriteErrorLog(ex);
                /*return view to error page*/
                return(View());
            }
            finally
            {
                traceLog.AppendLine("UpdateTrainer end() : --- " + DateTime.Now.ToLongDateString());
                LogManager.LogManagerInstance.WriteTraceLog(traceLog);
            }
        }