コード例 #1
0
        public string UpdateProfileRemark(ProfileRemarkVM remark)
        {
            string remarkId = string.Empty;

            SqlParameter[] parameters =
            {
                new SqlParameter {
                    ParameterName = "@Id", Value = remark.Id
                },
                new SqlParameter {
                    ParameterName = "@ProfileId", Value = remark.ProfileId
                },
                new SqlParameter {
                    ParameterName = "@Remarks", Value = remark.Remarks
                },
                new SqlParameter {
                    ParameterName = "@UpdatedBy", Value = remark.UpdatedBy
                },
                new SqlParameter {
                    ParameterName = "@UpdatedOn", Value = remark.UpdatedOn
                },
            };

            remarkId = Convert.ToString(DALHelper.ExecuteScalar("UpdateProfileRemark", parameters));

            return(remarkId);
        }
コード例 #2
0
        public ActionResult UpdateProfileRemark(ProfileRemarkVM model)
        {
            try
            {
                string remarkId = string.Empty;
                model.UpdatedOn = DateTime.Now;
                model.UpdatedBy = LogInManager.LoggedInUserId;

                remarkId = profileRepository.UpdateProfileRemark(model);

                if (!string.IsNullOrWhiteSpace(remarkId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            RemarkId = remarkId
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Remarks not updated successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "UpdateProfileRemark");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }
コード例 #3
0
        public ActionResult EditIndividualProfile(IndividualProfileVM model)
        {
            try
            {
                string profileId = string.Empty;

                model.CarRegistrationNo = Utility.Utility.ToUpperCase(model.CarRegistrationNo);
                model.UpdatedBy         = LogInManager.LoggedInUserId;

                profileId = profileRepository.UpdateIndividualProfile(model);

                if (!string.IsNullOrWhiteSpace(profileId))
                {
                    #region Save Profile Preference Mapping

                    var preferenceItems = model.PreferenceItems;

                    string[] preferenceItemsArr = null;

                    if (!string.IsNullOrWhiteSpace(preferenceItems))
                    {
                        preferenceItemsArr = preferenceItems.Split(',');

                        if (preferenceItemsArr != null)
                        {
                            //Remove Duplication.
                            preferenceItemsArr = preferenceItemsArr.Distinct().ToArray();
                        }
                    }

                    //Delete Existing Profile Preference Mapping.
                    //preferenceRepository.DeleteProfilePreferenceMappingByProfile(model.ProfileTypeId, model.Id);

                    #region Delete Preference Mapping

                    var preferenceMappings = preferenceRepository.GetProfilePreferenceMapping(model.ProfileTypeId, model.Id, null, LogInManager.LoggedInUserId);

                    if (preferenceMappings != null && preferenceMappings.Count > 0)
                    {
                        List <Guid> preferenceMappingIds = new List <Guid>();

                        foreach (var preferenceMapping in preferenceMappings)
                        {
                            if (preferenceMapping.PreferenceId.HasValue)
                            {
                                if (preferenceItemsArr == null || !preferenceItemsArr.Contains(preferenceMapping.PreferenceId.Value.ToString()))
                                {
                                    preferenceMappingIds.Add(preferenceMapping.Id);
                                }
                            }
                        }

                        //Delete Preference Mapping
                        if (preferenceMappingIds != null && preferenceMappingIds.Count > 0)
                        {
                            foreach (var mappingId in preferenceMappingIds)
                            {
                                preferenceRepository.DeleteProfilePreferenceMapping(mappingId, LogInManager.LoggedInUserId);
                            }
                        }
                    }

                    #endregion

                    if (preferenceItemsArr != null)
                    {
                        foreach (var item in preferenceItemsArr)
                        {
                            //Save Profile Preference Mapping.
                            ProfilePreferenceMappingVM profilePreferenceMappingVM = new ProfilePreferenceMappingVM();
                            profilePreferenceMappingVM.ProfileTypeId = model.ProfileTypeId;
                            profilePreferenceMappingVM.PreferenceId  = Guid.Parse(item);
                            profilePreferenceMappingVM.ProfileId     = Guid.Parse(profileId);
                            profilePreferenceMappingVM.CreatedBy     = LogInManager.LoggedInUserId;

                            preferenceRepository.AddProfilePreferenceMapping(profilePreferenceMappingVM);
                        }
                    }

                    #endregion

                    #region Add Profile Remarks

                    if (!string.IsNullOrWhiteSpace(model.Remarks))
                    {
                        ProfileRemarkVM remark = new ProfileRemarkVM();
                        remark.ProfileId = Guid.Parse(profileId);
                        remark.Remarks   = model.Remarks;
                        remark.CreatedBy = LogInManager.LoggedInUserId;
                        if (!remark.CreatedOn.HasValue)
                        {
                            remark.CreatedOn = DateTime.Now;
                        }

                        profileRepository.AddProfileRemark(remark);
                    }

                    #endregion

                    #region Record Activity Log
                    RecordActivityLog.RecordActivity(Pages.INDIVIDUAL_PROFILE, string.Format("Updated profile of {0} {1}.", model.LastName, model.FirstName));
                    #endregion

                    #region  Check Source Parameters
                    if (Request.Form["Source"] != null && !string.IsNullOrWhiteSpace(Convert.ToString(Request.Form["Source"])))
                    {
                        string source = string.Empty;
                        string url    = string.Empty;
                        string qid    = string.Empty;

                        source = Convert.ToString(Request.Form["Source"]);

                        if (source == "RateQuery")
                        {
                            TempData["ProfileId"]   = profileId;
                            TempData["FirstName"]   = model.FirstName;
                            TempData["LastName"]    = model.LastName;
                            TempData["CountryId"]   = model.CountryId;
                            TempData["TelephoneNo"] = model.TelephoneNo;
                            //TempData["Remarks"] = model.Remarks;

                            url = Url.Action("RateQuery", "Reservation");
                        }
                        else if (source == "CreateReservation")
                        {
                            TempData["TitleId"]     = model.TitleId;
                            TempData["ProfileId"]   = profileId;
                            TempData["FirstName"]   = model.FirstName;
                            TempData["LastName"]    = model.LastName;
                            TempData["CountryId"]   = model.CountryId;
                            TempData["TelephoneNo"] = model.TelephoneNo;
                            //TempData["Remarks"] = model.Remarks;

                            url = Url.Action("Create", "Reservation");
                        }
                        else if (source == "EditReservation")
                        {
                            qid = Convert.ToString(Request.Form["Qid"]);

                            TempData["TitleId"]     = model.TitleId;
                            TempData["ProfileId"]   = profileId;
                            TempData["FirstName"]   = model.FirstName;
                            TempData["LastName"]    = model.LastName;
                            TempData["CountryId"]   = model.CountryId;
                            TempData["TelephoneNo"] = model.TelephoneNo;
                            //TempData["Remarks"] = model.Remarks;

                            url = Url.Action("Edit", "Reservation", new { Id = qid });
                        }
                        else if (source == "SearchArrivals")
                        {
                            TempData["TitleId"]     = model.TitleId;
                            TempData["ProfileId"]   = profileId;
                            TempData["FirstName"]   = model.FirstName;
                            TempData["LastName"]    = model.LastName;
                            TempData["CountryId"]   = model.CountryId;
                            TempData["TelephoneNo"] = model.TelephoneNo;
                            //TempData["Remarks"] = model.Remarks;

                            url = Url.Action("Arrivals", "FrontDesk");
                        }
                        else if (source == "BulkReservation")
                        {
                            url = Url.Action("BulkReservation", "Common");
                        }
                        else if (source == "EditBulkReservation")
                        {
                            qid = Convert.ToString(Request.Form["Qid"]);

                            url = Url.Action("EditBulkReservation", "Common", new { Id = qid });
                        }

                        if (!string.IsNullOrWhiteSpace(url))
                        {
                            return(Json(new
                            {
                                IsSuccess = true,
                                IsExternalUrl = true,
                                data = url
                            }, JsonRequestBehavior.AllowGet));
                        }
                    }
                    #endregion

                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            ProfileId = model.Id
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Individual profile not updated successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "EditIndividualProfile");
                return(Json(new { IsSuccess = false, errorMessage = e.Message }));
            }
        }