Beispiel #1
0
        public ActionResult ActionSaveUpdate(TrainingInquiryModel model, string tranMode)
        {
            int    id       = model.PId;
            string saveMode = string.Empty;

            GetViewModel(id, tranMode, true);

            string viewPagePath = string.Empty;
            string vucPagePath  = "VUC_Add";

            if (ModelState.IsValid)
            {
                try
                {
                    _response = _provider.ActionSaveUpdate(model, tranMode);
                }
                catch (Exception ex)
                {
                    _response = new ServiceResponse(ex.Message, MessageType.Exception, false);
                }
            }
            else
            {
                _response = new ServiceResponse("Invalid Fields. Please fill mandatory fields!!", MessageType.Error, false);
            }
            TempData["ActionResponse"] = _response;
            if (Request.IsAjaxRequest())
            {
                return(PartialView(vucPagePath, _modObj));
            }
            else
            {
                return(View(viewPagePath, _modObj));
            }
        }
Beispiel #2
0
 public ServiceResponse Save(TrainingInquiryModel model)
 {
     try
     {
         using (var ts = new TransactionScope(TransactionScopeOption.Required))
         {
             Core_TrainingSession obj = new Core_TrainingSession
             {
                 FullName           = model.FullName,
                 CompanyName        = model.CompanyName,
                 EmailAddress       = model.EmailAddress,
                 ContactNo          = model.ContactNo,
                 IsAgent            = model.IsAgent,
                 ObjectiveOfTraning = model.ObjectiveOfTraning,
                 PreferredDay       = model.PreferredDay,
                 PrefferedTime      = model.PrefferedTime,
                 Remarks            = model.Remarks,
             };
             _ent.AddToCore_TrainingSession(obj);
             _ent.SaveChanges();
             ts.Complete();
             _response = new ServiceResponse("Record successfully created!!", MessageType.Success, true, "Edit");
             return(_response);
         }
     }
     catch (SqlException ex)
     {
         _response = new ServiceResponse(ServiceResponsesProvider.SqlExceptionMessage(ex), MessageType.SqlException, false);
     }
     catch (Exception ex)
     {
         _response = new ServiceResponse(ex.Message, MessageType.Exception, false, "Edit");
     }
     return(_response);
 }
Beispiel #3
0
        public IEnumerable <TrainingInquiryModel> GetList()
        {
            List <TrainingInquiryModel> model = new List <TrainingInquiryModel>();
            var result = _ent.Core_TrainingSession;

            foreach (var item in result)
            {
                TrainingInquiryModel obj = new TrainingInquiryModel
                {
                    PId                = item.TrainingSessionId,
                    FullName           = item.FullName,
                    CompanyName        = item.CompanyName,
                    EmailAddress       = item.EmailAddress,
                    ContactNo          = item.ContactNo,
                    IsAgent            = item.IsAgent,
                    ObjectiveOfTraning = item.ObjectiveOfTraning,
                    PreferredDay       = item.PreferredDay,
                    PrefferedTime      = item.PrefferedTime,
                    Remarks            = item.Remarks,
                };
                model.Add(obj);
            }

            return(model.AsEnumerable());
        }
Beispiel #4
0
        private TrainingInquiryModel GetViewModel(int id, string tranMode, bool isPost = false)
        {
            ///tranMode = "N" , "U", "L", "V"

            if (id != 0 && isPost == false)
            {
                _modObj = _provider.GetDetails(id);
            }
            SetUpFormParams(tranMode);
            return(_modObj);
        }
Beispiel #5
0
 public ActionResult Add(TrainingInquiryModel model)
 {
     //return ActionSaveUpdate(model, "N");
     ActionSaveUpdate(model, "N");
     if (_response.ResponseStatus == true)
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("Add", _modObj));
     }
 }
Beispiel #6
0
        public TrainingInquiryModel GetDetails(int PId)
        {
            var result = _ent.Core_TrainingSession.Where(x => x.TrainingSessionId == PId).FirstOrDefault();
            TrainingInquiryModel obj = new TrainingInquiryModel
            {
                PId                = result.TrainingSessionId,
                FullName           = result.FullName,
                CompanyName        = result.CompanyName,
                EmailAddress       = result.EmailAddress,
                ContactNo          = result.ContactNo,
                IsAgent            = result.IsAgent,
                ObjectiveOfTraning = result.ObjectiveOfTraning,
                PreferredDay       = result.PreferredDay,
                PrefferedTime      = result.PrefferedTime,
                Remarks            = result.Remarks,
            };

            return(obj);
        }
Beispiel #7
0
        public ServiceResponse ActionSaveUpdate(TrainingInquiryModel model, string tranMode)
        {
            try
            {
                if (tranMode == "N")
                {
                    return(Save(model));
                }
                else if (tranMode == "U")
                {
                    return(Edit(model));
                }
            }
            catch (SqlException ex)
            {
                _response = new ServiceResponse(ServiceResponsesProvider.SqlExceptionMessage(ex), MessageType.SqlException, false);
            }
            catch (Exception ex)
            {
                _response = new ServiceResponse(ex.Message, MessageType.Exception, false);
            }

            return(_response);
        }
Beispiel #8
0
        public ServiceResponse Edit(TrainingInquiryModel model)
        {
            try
            {
                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    var result = _ent.Core_TrainingSession.Where(x => x.TrainingSessionId == model.PId).FirstOrDefault();
                    if (result != null)
                    {
                        result.FullName           = model.FullName;
                        result.CompanyName        = model.CompanyName;
                        result.EmailAddress       = model.EmailAddress;
                        result.ContactNo          = model.ContactNo;
                        result.IsAgent            = model.IsAgent;
                        result.ObjectiveOfTraning = model.ObjectiveOfTraning;
                        result.PreferredDay       = model.PreferredDay;
                        result.PrefferedTime      = model.PrefferedTime;
                        result.Remarks            = model.Remarks;

                        _ent.ApplyCurrentValues(result.EntityKey.EntitySetName, result);
                        _ent.SaveChanges();
                    }
                    ts.Complete();
                    _response = new ServiceResponse("Record successfully updated!!", MessageType.Success, true, "Edit");
                }
            }
            catch (SqlException ex)
            {
                _response = new ServiceResponse(ServiceResponsesProvider.SqlExceptionMessage(ex), MessageType.SqlException, false);
            }
            catch (Exception ex)
            {
                _response = new ServiceResponse(ex.Message, MessageType.Exception, false, "Edit");
            }
            return(_response);
        }
Beispiel #9
0
 public ActionResult Edit(int id, TrainingInquiryModel model)
 {
     model.PId = id;
     return(ActionSaveUpdate(model, "U"));
 }
Beispiel #10
0
 public ActionResult Page(int?page, string extraParams)
 {
     _modObj = GetViewModelList(page);
     return(View("Index", _modObj));
 }