public ActionResult GroupServiceRequestList(SrSearchFilter searchFilter) { try { Logger.Info(_logMsg.Clear().SetPrefixMsg("Get GroupServiceRequestList").Add("UserId", this.UserInfo.UserId).ToInputLogString()); _userFacade = new UserFacade(); _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); HomeViewModel homeVM = new HomeViewModel(); homeVM.GroupSrSearchFilter = searchFilter; var lstDummyUser = _userFacade.GetDummyUsers(this.UserInfo); homeVM.GroupSrSearchFilter.OwnerList = lstDummyUser; homeVM.GroupServiceRequestList = _customerFacade.GetSrList(homeVM.GroupSrSearchFilter); ViewBag.GroupPageSize = homeVM.GroupSrSearchFilter.PageSize; ViewBag.GroupPageSizeList = _commonFacade.GetPageSizeList(); Logger.Info(_logMsg.Clear().SetPrefixMsg("Get GroupServiceRequestList").ToSuccessLogString()); return(PartialView("~/Views/Home/_GroupServiceRequestList.cshtml", homeVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Get GroupServiceRequestList").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult ContactList(RelationshipSearchFilter searchFilter) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Contact").Add("Status", searchFilter.Status) .Add("RelationshipName", searchFilter.RelationshipName).Add("RelationshipDesc", searchFilter.RelationshipDesc)); try { if (ModelState.IsValid) { _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); ContactViewModel contactVM = new ContactViewModel(); contactVM.SearchFilter = searchFilter; contactVM.RelationshipList = _customerFacade.GetAllRelationships(searchFilter); ViewBag.PageSize = contactVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); return(PartialView("~/Views/Contact/_ContactList.cshtml", contactVM)); } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors() })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Contact").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public CustomerController(ICorrelationContextAccessor correlationContext, ILogger <CustomerController> logger, ICustomerFacade customerFacade) { _logger = logger; _correlationContext = correlationContext; _customerFacade = customerFacade; }
public void Setup() { _mockLog = MockRepository.GenerateMock <ILog>(); _mockLog.Expect(e => e.Debug(Arg <object> .Is.Anything)).Repeat.Once(); Logger.Log = _mockLog; _customerFacade = new CustomerFacade(MockRepository.GenerateMock <ICustomerService>()); }
public ActionResult InitViewDetailProduct(int?customerId, string product, string productGroup, string subscriptionCode) { Logger.Info(_logMsg.Clear().SetPrefixMsg("InitViewDetailProduct").ToInputLogString()); try { _customerFacade = new CustomerFacade(); ExistingProductViewModel productVM = new ExistingProductViewModel(); ExistingProductSearchFilter searchFilter = new ExistingProductSearchFilter { CustomerId = customerId, ProductType = product, ProductGroup = productGroup, SubscriptionCode = subscriptionCode }; productVM.DetailProduct = _customerFacade.GetExistingProductDetail(searchFilter); return(PartialView("~/Views/ExistingProduct/_DetailProduct.cshtml", productVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("InitViewDetailProduct").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public JsonResult DeleteAttachment(int attachmentId) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Attachment").Add("AttachmentId", attachmentId).ToInputLogString()); try { _customerFacade = new CustomerFacade(); _customerFacade.DeleteCustomerAttachment(attachmentId, this.UserInfo.UserId); return(Json(new { Valid = true })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Attachment").Add("Error Message", ex.Message).ToFailLogString()); return(Json(new { Valid = false, Error = Resource.Error_System, Errors = string.Empty })); } }
public ActionResult CustomerSrList(SrSearchFilter searchFilter) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Search SR").Add("CustomerId", searchFilter.CustomerId) .ToInputLogString()); try { if (ModelState.IsValid) { //ViewBag.userId = this.UserInfo.UserId; _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); _userFacade = new UserFacade(); SrViewModel srVM = new SrViewModel(); if (searchFilter.CurrentUserId != UserInfo.UserId) { // First Load OR Change User searchFilter.CurrentUserId = UserInfo.UserId; searchFilter.CanViewAllUsers = null; searchFilter.CanViewUserIds = string.Empty; searchFilter.CanViewSrPageIds = string.Empty; } if (searchFilter.CurrentUserRoleCode != UserInfo.RoleCode) { // First Load OR Change Role searchFilter.CurrentUserRoleCode = UserInfo.RoleCode; } srVM.SearchFilter = searchFilter; srVM.SrList = _customerFacade.GetSrList(srVM.SearchFilter); ViewBag.PageSize = srVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); // Set ViewBag.OwnerList var lstEmployeeUser = _userFacade.GetEmployees(this.UserInfo); lstEmployeeUser.Add(this.UserInfo); // add current user ViewBag.OwnerList = lstEmployeeUser.Select(x => x.UserId).ToList(); // for enabled btnEdit Logger.Info(_logMsg.Clear().SetPrefixMsg("CustomerSrList").ToSuccessLogString()); return(PartialView("~/Views/SR/_CustomerSrList.cshtml", srVM)); } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors() })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Search SR").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public CustomerController(ICustomerFacade customerFacade) { if (customerFacade == null) { throw new ArgumentNullException(nameof(customerFacade)); } _customerFacade = customerFacade; }
public ProductController(IProductFacade productFacade, IAuctionFacade auctionFacade, IProductFactory productFactory, ICustomerFacade customerFacade) : base(customerFacade) { _productFacade = productFacade; _auctionFacade = auctionFacade; _productFactory = productFactory; }
public AccountController(ILogger <AccountController> logger, IHttpClientFactory clientFactory, ICustomerFacade customerFacade) { _logger = logger; _clientFactory = clientFactory; _customerFacade = customerFacade; }
public OrderFeedbackFacade(IRepository repository, IOrderFacade orderFacade, ICustomerFacade customerFacade, IProductFacade productFacade, IDistributedCacheManager distributedCacheManager, IOptions <CacheOptions> cacheOptions) : base(distributedCacheManager, cacheOptions) { _repository = repository; _orderFacade = orderFacade; _customerFacade = customerFacade; _productFacade = productFacade; _orderFeedbackManager = _repository.GetManagerInstance <OrderFeedbackManager>(); }
public ActionResult IndividualServiceRequestList(SrSearchFilter searchFilter) { try { Logger.Info(_logMsg.Clear().SetPrefixMsg("Get IndividualServiceRequestList").Add("UserId", this.UserInfo.UserId) .ToInputLogString()); _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); var lstEmployeeUser = new List <UserEntity>(); // กรณีเลือก ทั้งหมด FilterType จะมีค่าเป็น null if (searchFilter.FilterType == null) { _userFacade = new UserFacade(); lstEmployeeUser = _userFacade.GetEmployees(this.UserInfo); } lstEmployeeUser.Add(this.UserInfo); // add current user if (searchFilter.CurrentUserId != UserInfo.UserId) { // First Load OR Change User searchFilter.CurrentUserId = UserInfo.UserId; searchFilter.CanViewAllUsers = null; searchFilter.CanViewUserIds = string.Empty; searchFilter.CanViewSrPageIds = string.Empty; } if (searchFilter.CurrentUserRoleCode != UserInfo.RoleCode) { // First Load OR Change Role searchFilter.CurrentUserRoleCode = UserInfo.RoleCode; } HomeViewModel homeVM = new HomeViewModel(); homeVM.IndividualSrSearchFilter = searchFilter; homeVM.IndividualSrSearchFilter.OwnerList = lstEmployeeUser; homeVM.IndividualServiceRequestList = _customerFacade.GetSrList(homeVM.IndividualSrSearchFilter); ViewBag.IndyPageSize = homeVM.IndividualSrSearchFilter.PageSize; ViewBag.IndyPageSizeList = _commonFacade.GetPageSizeList(); Logger.Info(_logMsg.Clear().SetPrefixMsg("Get IndividualServiceRequestList").ToSuccessLogString()); return(PartialView("~/Views/Home/_IndividualServiceRequestList.cshtml", homeVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Get IndividualServiceRequestList").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult List(int?customerId = null) { Logger.Info(_logMsg.Clear().SetPrefixMsg("List SR").ToInputLogString()); try { CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel(); ViewBag.userId = this.UserInfo.UserId; if (TempData["CustomerInfo"] != null) { custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"]; TempData["CustomerInfo"] = custInfoVM; // keep for change Tab } else { return(RedirectToAction("Search", "Customer")); } _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); SrViewModel srVM = new SrViewModel(); srVM.CustomerInfo = custInfoVM; if (custInfoVM.CustomerId.HasValue) { // SR list srVM.SearchFilter = new SrSearchFilter { CustomerId = custInfoVM.CustomerId.Value, PageNo = 1, PageSize = _commonFacade.GetPageSizeStart(), SortField = "CreateDate", SortOrder = "ASC" }; //srVM.SrList = _customerFacade.GetSrList(srVM.SearchFilter); ViewBag.PageSize = srVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.Message = string.Empty; } return(View(srVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List SR").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult List(int?customerId = null) { try { CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel(); if (TempData["CustomerInfo"] != null) { custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"]; TempData["CustomerInfo"] = custInfoVM; // Keep for change Tab } else { return(RedirectToAction("Search", "Customer")); } Logger.Info(_logMsg.Clear().SetPrefixMsg("List Document").Add("CustomerId", custInfoVM.CustomerId).ToInputLogString()); _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); DocumentViewModel documentVM = new DocumentViewModel(); documentVM.CustomerInfo = custInfoVM; if (custInfoVM.CustomerId.HasValue) { // Attachment list documentVM.SearchFilter = new AttachmentSearchFilter { CustomerId = custInfoVM.CustomerId.Value, PageNo = 1, PageSize = _commonFacade.GetPageSizeStart(), SortField = "ExpiryDate", SortOrder = "DESC" }; documentVM.AttachmentList = _customerFacade.GetAttachmentList(documentVM.SearchFilter); ViewBag.CurrentUserId = this.UserInfo.UserId; // for check btnEdit btnDelete ViewBag.PageSize = documentVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.Message = string.Empty; } return(View(documentVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Customer").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult List(string encryptedString) { int?customerId = encryptedString.ToCustomerId(); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").ToInputLogString()); try { if (customerId == null) { return(RedirectToAction("Search", "Customer")); } Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").Add("CustomerId", customerId).ToInputLogString()); _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); CustomerContactViewModel contactVM = new CustomerContactViewModel(); CustomerInfoViewModel custInfoVM = this.MappingCustomerInfoView(customerId.Value); contactVM.CustomerInfo = custInfoVM; if (custInfoVM.CustomerId.HasValue) { // Contact list contactVM.SearchFilter = new ContactSearchFilter { CustomerId = custInfoVM.CustomerId.Value, PageNo = 1, PageSize = _commonFacade.GetPageSizeStart(), SortField = "CardNo", SortOrder = "ASC" }; contactVM.ContactList = _customerFacade.GetContactList(contactVM.SearchFilter); ViewBag.PageSize = contactVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.Message = string.Empty; } return(View(contactVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult InitEditContactRelationship(string jsonData) { Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit ContactRelationship").Add("JsonContactRelationship", jsonData).ToInputLogString()); try { _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); var contactRelationVM = JsonConvert.DeserializeObject <ContactRelationshipViewModel>(jsonData); if (contactRelationVM.ListIndex != null) { CustomerContactEntity selected = contactRelationVM.ContactRelationshipList[contactRelationVM.ListIndex.Value]; contactRelationVM.AccountId = selected.AccountId; contactRelationVM.RelationshipId = selected.RelationshipId; contactRelationVM.Product = selected.Product; } if (contactRelationVM.CustomerId.HasValue) { var listAccount = _customerFacade.GetAccountByCustomerId(contactRelationVM.CustomerId.Value); TempData["AccountList"] = listAccount; // keep AccountList contactRelationVM.AccountList = new SelectList((IEnumerable)listAccount.Select(x => new { key = x.AccountId, value = x.ProductAndAccountNoDisplay }).ToDictionary(t => t.key, t => t.value), "Key", "Value", string.Empty); } // Get SelectList var lstRelationship = _commonFacade.GetRelationshipSelectList(); TempData["RelationshipList"] = lstRelationship; // Keep RelationshipList contactRelationVM.RelationshipList = new SelectList((IEnumerable)lstRelationship, "Key", "Value", string.Empty); return(PartialView("~/Views/Contact/_EditContactRelationship.cshtml", contactRelationVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit ContactRelationship").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult Edit(ContactViewModel contactVM) // Mater Relationship { Logger.Info(_logMsg.Clear().SetPrefixMsg("Save ContactRelationship").Add("Status", contactVM.Status) .Add("RelationshipName", contactVM.RelationshipName).Add("RelationshipDesc", contactVM.RelationshipDesc).ToInputLogString()); try { if (ModelState.IsValid) { RelationshipEntity relationEntity = new RelationshipEntity { RelationshipId = contactVM.RelationshipId.HasValue ? contactVM.RelationshipId.Value : 0, Status = contactVM.Status, RelationshipName = contactVM.RelationshipName, RelationshipDesc = contactVM.RelationshipDesc, CreateUser = UserInfo, //When save the progame will select to save this parameter UpdateUser = UserInfo }; _customerFacade = new CustomerFacade(); // Check Duplicate if (_customerFacade.IsDuplicateRelationship(relationEntity) == true) { ViewBag.ErrorMessage = Resource.Error_SaveFailedDuplicate; goto Outer; } bool success = _customerFacade.SaveContactRelation(relationEntity); if (success) { return(RedirectToAction("Search", "Contact")); } ViewBag.ErrorMessage = Resource.Error_SaveFailed; } Outer: TempData["contactVM"] = contactVM; return(InitEdit()); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Save ContactRelationship").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
/// <summary> /// Dependency injection container for all the system's entities /// </summary> /// <param name="config">Configuration provider, defaults to DefaultConfig.cs</param> /// <param name="cache">Cache wrapper, defaults to SimpleInMemoryCache</param> /// <param name="dbWrapper">DB Wrapper, especially useful for tests. Defauls to RelationalDatabaseWrapper</param> /// <param name="customersFacade">A facade to customers data. Defaults to CustomersDbManager</param> /// <param name="taxesFacade">A facade to taxes data. Defaults to TaxesDbManager</param> /// <param name="ordersFacade">A facade to orders data. Defaults to OrdersDbManager</param> public DefaultContainer( IConfig config = null, IKeyValueCache cache = null, IDatabaseWrapper dbWrapper = null, ICustomerFacade customersFacade = null, ITaxesFacade taxesFacade = null, IOrdersFacade ordersFacade = null) { Config = config ?? new DefaultConfig(); Logger = new StreamLogger(Console.OpenStandardOutput()); Cache = cache ?? new SimpleInMemoryCache(); DbWrapper = dbWrapper ?? new RelationalDatabaseWrapper(Config.DATABASE_URL, Cache, Config.ROOT_QUERIES_DIR, Logger); CustomersFacade = customersFacade ?? new CustomersDbManager(DbWrapper); TaxesFacade = taxesFacade ?? new TaxesDbManager(DbWrapper); OrdersFacade = ordersFacade ?? new OrdersDbManager(DbWrapper); }
public ActionResult ReceiveCall() { var dic = ApplicationHelpers.GetParams(Request.Url.Query); string callId = dic["callid"]; string phoneNo = dic["phoneno"]; string cardNo = dic["cardno"]; string callType = dic["calltype"]; string ivrLang = dic["ivrlang"]; Logger.Info(_logMsg.Clear().SetPrefixMsg("Receive Call").Add("CallId", callId).Add("PhoneNo", phoneNo) .Add("CardNo", cardNo.MaskCardNo()).Add("CallType", callType).Add("RequestUrl", Request.Url.AbsoluteUri).ToInputLogString()); try { // Reset routedata RouteData.Values.Remove("callId"); RouteData.Values.Remove("phoneNo"); if (string.IsNullOrWhiteSpace(callId) || string.IsNullOrWhiteSpace(phoneNo) || string.IsNullOrWhiteSpace(callType)) { goto Outer; } _customerFacade = new CustomerFacade(); bool success = _customerFacade.SaveCallId(callId, phoneNo, cardNo, callType.ToUpper(CultureInfo.InvariantCulture) , this.UserInfo.UserId, ivrLang.ToUpper(CultureInfo.InvariantCulture)); if (success) { RouteValueDictionary dict = new RouteValueDictionary(); dict.Add("callId", callId); dict.Add("phoneNo", phoneNo); return(RedirectToAction("Search", "Customer", dict)); } } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Receive Call").Add("Error Message", ex.Message).ToFailLogString()); } Outer: return(RedirectToAction("Search", "Customer")); }
public ActionResult List(string encryptedString) { int?customerId = encryptedString.ToCustomerId(); Logger.Info(_logMsg.Clear().SetPrefixMsg("List ExistingProduct").Add("CustomerId", customerId).ToInputLogString()); try { _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); ExistingProductViewModel productVM = new ExistingProductViewModel(); CustomerInfoViewModel custInfoVM = this.MappingCustomerInfoView(customerId.Value); productVM.CustomerInfo = custInfoVM; if (custInfoVM.CustomerId.HasValue) { productVM.SearchFilter = new AccountSearchFilter { CustomerId = custInfoVM.CustomerId.Value, PageNo = 1, PageSize = _commonFacade.GetPageSizeStart(), SortField = "ProductGroup", SortOrder = "ASC" }; productVM.AccountList = _customerFacade.GetAccountList(productVM.SearchFilter); ViewBag.PageSize = productVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.Message = string.Empty; } return(View(productVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List ExistingProduct").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult CustomerAttachmentList(AttachmentSearchFilter searchFilter) { Logger.Info(_logMsg.Clear().SetPrefixMsg("List CustomerAttachment").Add("CustomerId", searchFilter.CustomerId) .ToInputLogString()); try { if (ModelState.IsValid) { _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); DocumentViewModel docVM = new DocumentViewModel(); docVM.SearchFilter = searchFilter; docVM.AttachmentList = _customerFacade.GetAttachmentList(docVM.SearchFilter); ViewBag.PageSize = docVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.CurrentUserId = this.UserInfo.UserId; // for check btnEdit btnDelete Logger.Info(_logMsg.Clear().SetPrefixMsg("CustomerAttachmentList").ToSuccessLogString()); return(PartialView("~/Views/Document/_CustomerAttachmentList.cshtml", docVM)); } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors() })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List CustomerAttachment").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public JsonResult DeleteCustomerContact(int customerContactId) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Contact").Add("ContactId", customerContactId).ToInputLogString()); try { _customerFacade = new CustomerFacade(); bool isSuccess = _customerFacade.DeleteCustomerContact(customerContactId, this.UserInfo.UserId); if (isSuccess) { return(Json(new { Valid = true })); } Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Contact").ToFailLogString()); return(Json(new { Valid = false, Error = "ไม่สามารถลบข้อมูลได้ เนื่องจากมีการใช้งานข้อมูลอยู่", Errors = string.Empty })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Contact").Add("Error Message", ex.Message).ToFailLogString()); return(Json(new { Valid = false, Error = Resource.Error_System, Errors = string.Empty })); } }
public ActionResult InitView(int attachmentId, string documentLevel) { Logger.Info(_logMsg.Clear().SetPrefixMsg("InitView Attachment").Add("AttachmentId", attachmentId). Add("DocumentLevel", documentLevel).ToInputLogString()); try { _customerFacade = new CustomerFacade(); var attachVM = new AttachViewModel(); AttachmentEntity selectedAttach = _customerFacade.GetAttachmentByID(attachmentId, documentLevel); if (selectedAttach != null) { attachVM.AttachmentId = selectedAttach.AttachmentId; attachVM.Filename = selectedAttach.Filename; attachVM.DocName = selectedAttach.Name; attachVM.DocDesc = selectedAttach.Description; attachVM.ExpiryDate = selectedAttach.ExpiryDateDisplay; attachVM.CustomerId = selectedAttach.CustomerId; attachVM.Status = selectedAttach.Status; attachVM.CreateUserFullName = selectedAttach.CreateUserFullName; attachVM.AttachTypeDisplay = StringHelpers.ConvertListToString(selectedAttach.AttachTypeList.Select(x => x.Name).ToList <object>(), ", "); } TempData["FILE_DOWNLOAD"] = selectedAttach; return(PartialView("~/Views/Document/_ViewAttachment.cshtml", attachVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("InitView Attachment").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult ExistingProductList(AccountSearchFilter searchFilter) { Logger.Info(_logMsg.Clear().SetPrefixMsg("ExistingProductList").Add("CustomerId", searchFilter.CustomerId) .ToInputLogString()); try { if (ModelState.IsValid) { _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); ExistingProductViewModel productVM = new ExistingProductViewModel(); productVM.SearchFilter = searchFilter; productVM.AccountList = _customerFacade.GetAccountList(productVM.SearchFilter); ViewBag.PageSize = productVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); Logger.Info(_logMsg.Clear().SetPrefixMsg("ExistingProductList").ToSuccessLogString()); return(PartialView("~/Views/ExistingProduct/_ExistingProductList.cshtml", productVM)); } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors() })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("ExistingProductList").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult ViewCallInfo(string callId) { Logger.Info(_logMsg.Clear().SetPrefixMsg("View CallInfo").Add("CallId", callId).ToInputLogString()); try { _customerFacade = new CustomerFacade(); var callInfo = _customerFacade.GetCallInfoByCallId(callId); if (callInfo != null) { Logger.Info(_logMsg.Clear().SetPrefixMsg("View CallInfo").Add("CallID", callInfo.CallId) .Add("CardNo", callInfo.CardNo.MaskCardNo()) .Add("CallType", callInfo.CallType) .ToSuccessLogString()); return(View("~/Views/Shared/_ViewCallInfo.cshtml", callInfo)); } return(Json(new { Valid = false, Error = Resource.Msg_NoRecords, Errors = string.Empty })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("View CallInfo").Add("Error Message", ex.Message).ToFailLogString()); return(Json(new { Valid = false, Error = Resource.Error_System, Errors = string.Empty })); } }
public ProgramStarter(ICustomerFacade facade) { _customerFacade = facade; }
public ControllerBase(ICustomerFacade customerFacade) { _customerFacade = customerFacade; }
public ActionResult ExistingLeadList() { CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel(); if (TempData["CustomerInfo"] != null) { custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"]; TempData["CustomerInfo"] = custInfoVM; // Keep for change Tab } else { return(RedirectToAction("Search", "Customer")); } Logger.Info(_logMsg.Clear().SetPrefixMsg("Get ExistingLead List").Add("CardNo", custInfoVM.CardNo.MaskCardNo()).ToInputLogString()); _auditLog = new AuditLogEntity(); _auditLog.Module = Constants.Module.Customer; _auditLog.Action = Constants.AuditAction.ExistingLead; _auditLog.IpAddress = ApplicationHelpers.GetClientIP(); _auditLog.Status = LogStatus.Success; _auditLog.CreateUserId = this.UserInfo.UserId; try { if (ModelState.IsValid) { _customerFacade = new CustomerFacade(); ExistingLeadViewModel existingLeadVM = new ExistingLeadViewModel(); if (!string.IsNullOrWhiteSpace(custInfoVM.CardNo)) { existingLeadVM.Ticket = _customerFacade.GetLeadList(_auditLog, custInfoVM.CardNo); } Logger.Info(_logMsg.Clear().SetPrefixMsg("Get ExistingLead List").ToSuccessLogString()); return(PartialView("~/Views/ExistingLead/_ExistingLeadList.cshtml", existingLeadVM)); } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors() })); } catch (CustomException cex) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Get ExistingLead List").Add("Error Message", cex.Message).ToFailLogString()); return(Json(new { Valid = false, Error = cex.Message })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Get ExistingLead List").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult InitEdit(int?relationshipId = null) { Logger.Info(_logMsg.Clear().SetPrefixMsg("IntEdit ContactRelationship").Add("RelationshipId", relationshipId).ToInputLogString()); try { ContactViewModel contactVM = null; if (TempData["contactVM"] != null) { contactVM = (ContactViewModel)TempData["contactVM"]; } else { contactVM = new ContactViewModel { RelationshipId = relationshipId }; } _commonFacade = new CommonFacade(); var statusList = _commonFacade.GetStatusSelectList(); contactVM.StatusList = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty); if (contactVM.RelationshipId != null) { _customerFacade = new CustomerFacade(); RelationshipEntity relationshipEntity = _customerFacade.GetRelationshipByID(contactVM.RelationshipId.Value); contactVM.RelationshipId = relationshipEntity.RelationshipId; contactVM.RelationshipName = relationshipEntity.RelationshipName; contactVM.RelationshipDesc = relationshipEntity.RelationshipDesc; contactVM.Status = relationshipEntity.Status; contactVM.CreateUser = relationshipEntity.CreateUserDisplay; contactVM.UpdateUser = relationshipEntity.UpdateUserDisplay; contactVM.CreatedDate = relationshipEntity.CreatedDate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime); contactVM.UpdateDate = relationshipEntity.Updatedate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime); } else { // default UserLogin if (this.UserInfo != null) { var today = DateTime.Now; contactVM.CreateUser = this.UserInfo.FullName; contactVM.CreatedDate = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime); contactVM.UpdateDate = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime); contactVM.UpdateUser = this.UserInfo.FullName; } } return(View("~/Views/Contact/Edit.cshtml", contactVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("IntEdit ContactRelationship").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public HomeController(IAuctionFacade auctionFacade, ICustomerFacade customerFacade) : base(customerFacade) { _auctionFacade = auctionFacade; }
public AuctionController(IAuctionFacade auctionFacade, IProductFacade productFacade, ICustomerFacade customerFacade) : base(customerFacade) { _auctionFacade = auctionFacade; _productFacade = productFacade; }
public AccountController(ICustomerFacade customerFacade) : base(customerFacade) { }
public ActionResult InitEditCustomerContact(int?contactId = null, int?customerId = null) { Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit CustomerContact").Add("ContactId", contactId) .Add("CustomerId", customerId).ToInputLogString()); try { ContactEditViewModel contactEditVM = new ContactEditViewModel(); _customerFacade = new CustomerFacade(); if (contactId.HasValue && customerId.HasValue) { var contactEntity = _customerFacade.GetContactByID(contactId.Value); contactEditVM.ContactId = contactEntity.ContactId; contactEditVM.SubscriptType = contactEntity.SubscriptType != null?contactEntity.SubscriptType.SubscriptTypeId.ConvertToString() : string.Empty; contactEditVM.TitleThai = contactEntity.TitleThai != null?contactEntity.TitleThai.TitleId.ConvertToString() : string.Empty; contactEditVM.TitleEnglish = contactEntity.TitleEnglish != null?contactEntity.TitleEnglish.TitleId.ConvertToString() : string.Empty; contactEditVM.FirstNameThai = contactEntity.FirstNameThai; contactEditVM.LastNameThai = contactEntity.LastNameThai; contactEditVM.TitleEnglish = contactEntity.TitleEnglish != null?contactEntity.TitleEnglish.TitleId.ConvertToString() : string.Empty; contactEditVM.FirstNameEnglish = contactEntity.FirstNameEnglish; contactEditVM.LastNameEnglish = contactEntity.LastNameEnglish; contactEditVM.CardNo = contactEntity.CardNo; contactEditVM.BirthDate = contactEntity.BirthDateDisplay; contactEditVM.Email = contactEntity.Email; contactEditVM.Fax = contactEntity.Fax; #region "Phone" // Phone if (contactEntity.PhoneList != null) { if (contactEntity.PhoneList.Count > 0) { contactEditVM.PhoneType1 = contactEntity.PhoneList[0].PhoneTypeId.ConvertToString(); contactEditVM.PhoneNo1 = contactEntity.PhoneList[0].PhoneNo; } else { contactEditVM.PhoneType1 = string.Empty; contactEditVM.PhoneNo1 = string.Empty; } if (contactEntity.PhoneList.Count > 1) { contactEditVM.PhoneType2 = contactEntity.PhoneList[1].PhoneTypeId.ConvertToString(); contactEditVM.PhoneNo2 = contactEntity.PhoneList[1].PhoneNo; } else { contactEditVM.PhoneType2 = string.Empty; contactEditVM.PhoneNo2 = string.Empty; } if (contactEntity.PhoneList.Count > 2) { contactEditVM.PhoneType3 = contactEntity.PhoneList[2].PhoneTypeId.ConvertToString(); contactEditVM.PhoneNo3 = contactEntity.PhoneList[2].PhoneNo; } else { contactEditVM.PhoneType3 = string.Empty; contactEditVM.PhoneNo3 = string.Empty; } } #endregion contactEditVM.IsEdit = contactEntity.IsEdit.Value ? "1" : "0"; contactEditVM.CustomerId = customerId; // keep CustomerId contactEditVM.IsConfirm = "1"; var contactRelationships = _customerFacade.GetContactRelationshipList(contactId.Value, customerId.Value); contactEditVM.ContactRelationshipList = contactRelationships; contactEditVM.JsonContactRelationship = JsonConvert.SerializeObject(contactRelationships); } else { contactEditVM.IsEdit = "1"; // case New } // Get SelectList _commonFacade = new CommonFacade(); contactEditVM.SubscriptTypeList = new SelectList((IEnumerable)_commonFacade.GetSubscriptTypeSelectList(), "Key", "Value", string.Empty); contactEditVM.TitleThaiList = new SelectList((IEnumerable)_commonFacade.GetTitleThaiSelectList(), "Key", "Value", string.Empty); contactEditVM.TitleEnglishList = new SelectList((IEnumerable)_commonFacade.GetTitleEnglishSelectList(), "Key", "Value", string.Empty); contactEditVM.PhoneTypeList = new SelectList((IEnumerable)_commonFacade.GetPhoneTypeSelectList(), "Key", "Value", string.Empty); return(PartialView("~/Views/Contact/_EditCustomerContact.cshtml", contactEditVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit CustomerContact").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult ManageContactRlat(ContactEditViewModel contactEditVM) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Edit Contact").Add("FirstNameThai", contactEditVM.FirstNameThai).ToInputLogString()); try { #region "Validate CardNo" if (!string.IsNullOrEmpty(contactEditVM.SubscriptType)) { _commonFacade = new CommonFacade(); var subscriptTypePersonal = _commonFacade.GetSubscriptTypeByCode(Constants.SubscriptTypeCode.Personal); if (string.IsNullOrEmpty(contactEditVM.CardNo)) { ModelState.AddModelError("CardNo", string.Format(CultureInfo.InvariantCulture, Resource.ValErr_RequiredField, Resource.Lbl_CardNo_Passport)); } else if (contactEditVM.SubscriptType.ToNullable <int>() == subscriptTypePersonal.SubscriptTypeId) { if (!ApplicationHelpers.ValidateCardNo(contactEditVM.CardNo)) { ModelState.AddModelError("CardNo", Resource.ValErr_InvalidCardNo); } } } #endregion #region "Validate FirstName" if (string.IsNullOrEmpty(contactEditVM.FirstNameThai) && string.IsNullOrEmpty(contactEditVM.FirstNameEnglish)) { ModelState.AddModelError("FirstNameThai", string.Format(CultureInfo.InvariantCulture, Resource.ValErr_RequiredField, Resource.Lbl_FirstNameThai_Contact)); } #endregion #region "Validate Phone" if (contactEditVM.IsEdit == "1") { if (string.IsNullOrEmpty(contactEditVM.PhoneType2)) { ModelState.Remove("PhoneNo2"); } if (string.IsNullOrEmpty(contactEditVM.PhoneType3)) { ModelState.Remove("PhoneNo3"); } // Check duplicate phoneNo if (!string.IsNullOrEmpty(contactEditVM.PhoneNo1) && !string.IsNullOrEmpty(contactEditVM.PhoneNo2)) { if (contactEditVM.PhoneNo1.Equals(contactEditVM.PhoneNo2)) { ModelState.AddModelError("PhoneNo1", Resource.ValError_DuplicatePhoneNo); ModelState.AddModelError("PhoneNo2", Resource.ValError_DuplicatePhoneNo); } } if (!string.IsNullOrEmpty(contactEditVM.PhoneNo1) && !string.IsNullOrEmpty(contactEditVM.PhoneNo3)) { if (contactEditVM.PhoneNo1.Equals(contactEditVM.PhoneNo3)) { ModelState.AddModelError("PhoneNo1", Resource.ValError_DuplicatePhoneNo); ModelState.AddModelError("PhoneNo3", Resource.ValError_DuplicatePhoneNo); } } if (!string.IsNullOrEmpty(contactEditVM.PhoneNo2) && !string.IsNullOrEmpty(contactEditVM.PhoneNo3)) { if (contactEditVM.PhoneNo2.Equals(contactEditVM.PhoneNo3)) { ModelState.AddModelError("PhoneNo2", Resource.ValError_DuplicatePhoneNo); ModelState.AddModelError("PhoneNo3", Resource.ValError_DuplicatePhoneNo); } } } else { // Phone ModelState.Remove("PhoneType1"); ModelState.Remove("PhoneNo1"); ModelState.Remove("PhoneNo2"); ModelState.Remove("PhoneNo3"); // Name ModelState.Remove("FirstNameThai"); ModelState.Remove("FirstNameEnglish"); ModelState.Remove("LastNameThai"); ModelState.Remove("LastNameEnglish"); } #endregion if (!string.IsNullOrEmpty(contactEditVM.BirthDate) && !contactEditVM.BirthDateValue.HasValue) { ModelState.AddModelError("BirthDate", Resource.ValErr_InvalidDate); } else if (!string.IsNullOrEmpty(contactEditVM.BirthDate) && contactEditVM.BirthDateValue.HasValue) { if (contactEditVM.BirthDateValue.Value > DateTime.Now.Date) { ModelState.AddModelError("BirthDate", Resource.ValErr_InvalidDate_MustLessThanToday); } } if (ModelState.IsValid) { _customerFacade = new CustomerFacade(); #region "Check Duplicate PhoneNo" List <string> lstPhoneNo = new List <string>(); if (!string.IsNullOrEmpty(contactEditVM.PhoneNo1)) { lstPhoneNo.Add(contactEditVM.PhoneNo1); } if (!string.IsNullOrEmpty(contactEditVM.PhoneNo2)) { lstPhoneNo.Add(contactEditVM.PhoneNo2); } if (!string.IsNullOrEmpty(contactEditVM.PhoneNo3)) { lstPhoneNo.Add(contactEditVM.PhoneNo3); } if (contactEditVM.IsEdit != "0") { contactEditVM.ContactList = _customerFacade.GetContactByPhoneNo(contactEditVM.ContactId, contactEditVM.FirstNameThai, contactEditVM.LastNameThai , contactEditVM.FirstNameEnglish, contactEditVM.LastNameEnglish, lstPhoneNo); } if (contactEditVM.ContactList != null && contactEditVM.ContactList.Any()) { if (contactEditVM.IsConfirm == "0") // Case New { // Show DuplicateList return(PartialView("~/Views/Contact/_ContactDuplicateList.cshtml", contactEditVM)); } else // Case Edit { // Alert Duplicate return(Json(new { Valid = false, Error = Resource.ValError_DuplicateContact, Errors = string.Empty })); } } #endregion ContactEntity contactEntity = new ContactEntity { ContactId = contactEditVM.ContactId, SubscriptType = new SubscriptTypeEntity { SubscriptTypeId = contactEditVM.SubscriptType.ToNullable <int>() }, CardNo = contactEditVM.CardNo, BirthDate = contactEditVM.BirthDateValue, TitleThai = new TitleEntity { TitleId = contactEditVM.TitleThai.ToNullable <int>() }, FirstNameThai = contactEditVM.FirstNameThai, LastNameThai = contactEditVM.LastNameThai, TitleEnglish = new TitleEntity { TitleId = contactEditVM.TitleEnglish.ToNullable <int>() }, FirstNameEnglish = contactEditVM.FirstNameEnglish, LastNameEnglish = contactEditVM.LastNameEnglish, Email = contactEditVM.Email, CreateUser = new UserEntity { UserId = this.UserInfo.UserId }, UpdateUser = new UserEntity { UserId = this.UserInfo.UserId }, CustomerId = contactEditVM.CustomerId // for add CustomerLog }; #region "Phone & Fax" // Phone & Fax contactEntity.PhoneList = new List <PhoneEntity>(); if (!string.IsNullOrEmpty(contactEditVM.PhoneNo1)) { contactEntity.PhoneList.Add(new PhoneEntity { PhoneTypeId = contactEditVM.PhoneType1.ToNullable <int>(), PhoneNo = contactEditVM.PhoneNo1 }); } if (!string.IsNullOrEmpty(contactEditVM.PhoneNo2)) { contactEntity.PhoneList.Add(new PhoneEntity { PhoneTypeId = contactEditVM.PhoneType2.ToNullable <int>(), PhoneNo = contactEditVM.PhoneNo2 }); } if (!string.IsNullOrEmpty(contactEditVM.PhoneNo3)) { contactEntity.PhoneList.Add(new PhoneEntity { PhoneTypeId = contactEditVM.PhoneType3.ToNullable <int>(), PhoneNo = contactEditVM.PhoneNo3 }); } // Fax if (!string.IsNullOrEmpty(contactEditVM.Fax)) { _commonFacade = new CommonFacade(); var phoneTypeFax = _commonFacade.GetPhoneTypeByCode(Constants.PhoneTypeCode.Fax); contactEntity.PhoneList.Add(new PhoneEntity { PhoneTypeId = phoneTypeFax.PhoneTypeId, PhoneNo = contactEditVM.Fax }); } #endregion // Save var contactRelationship = contactEditVM.ContactRelationshipList.Where(x => x.IsEdit == true).ToList(); bool isSuccess = false; if (contactEditVM.IsConfirm == "0") { isSuccess = _customerFacade.SaveContact(contactEntity, null); // save contact only } else { #region "Validate ContactRelationship" if (contactEditVM.ContactRelationshipList.Count(x => x.CustomerId == contactEditVM.CustomerId) == 0) { // Alert return(Json(new { Valid = false, Error = Resource.Msg_PleaseInputRelationship, Errors = string.Empty })); } #endregion isSuccess = _customerFacade.SaveContact(contactEntity, contactRelationship); // save contact & relationship } if (isSuccess) { return(Json(new { Valid = true, contactId = contactEntity.ContactId, })); } else { return(Json(new { Valid = false, Error = Resource.Error_System, Errors = string.Empty })); } } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors() })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Edit Contact").Add("Error Message", ex.Message).ToFailLogString()); return(Json(new { Valid = false, Error = Resource.Error_System, Errors = string.Empty })); } }