Example #1
0
        public string SaveDraft(FormDataCollection form)
        {
            // Check account user form
            var employeeType = (EmployeeType)form.Get("employeeTypeId").ToInt32();
            var status = StoreData.CheckAccountUseHandover(employeeType);
            if (!status.IsStringNullOrEmpty()) return status;

            var typeIds = form.Get("typeIds");
            var levelIds = form.Get("levelIds");
            var importIds = form.Get("importIds");
            var statusIds = form.Get("statusIds");
            var channelIds = form.Get("channelIds");
            var containerIds = form.Get("containerIds");
            var branchId = UserContext.GetDefaultBranch();
            var channelAmounts = form.Get("channelAmounts");

            try
            {
                var listContact = ContactRepository.FilterHandover(branchId, typeIds, levelIds, importIds, statusIds, containerIds, channelIds, channelAmounts, employeeType) ?? new List<ContactInfo>();
                var arrUser = ConvertHelper.ToString(form.Get("users")).Split(',');
                if (arrUser.Length <= 0) return "Không có TVTS để lưu nháp";
                var arrAmount = ConvertHelper.ToString(form.Get("amounts")).Split(',');
                if (arrAmount.Length <= 0) return "Không có Contact để lưu nháp";
                if (arrUser.Length != arrAmount.Length) return "TVTS và số lượng Contact không phù hợp";

                var index = 0;
                for (var i = 0; i < arrUser.Length; i++)
                {
                    var user = ConvertHelper.ToInt32(arrUser[i]);
                    var amount = ConvertHelper.ToInt32(arrAmount[i]);
                    if (amount == 0) continue;

                    var ids = listContact
                        .Skip(index)
                        .Take(amount)
                        .Select(c => c.Id.ToString())
                        .Aggregate((totalItem, current) => totalItem + ", " + current);
                    ContactRepository.ContactUpdateDraft(ids, user, 1, employeeType);
                    index += amount;
                }

                // Update Account Draft
                var account = new UserDraftInfo
                              {
                                  CreatedDate = DateTime.Now,
                                  BranchId = UserContext.GetDefaultBranch(),
                                  UserId = UserContext.GetCurrentUser().UserID,
                                  IsDraftConsultant = employeeType == EmployeeType.Consultant,
                                  IsDraftCollabortor = employeeType == EmployeeType.Collaborator,
                              };
                UserDraftRepository.Update(account);
                return "Lưu nháp thành công";
            }
            catch(Exception ex)
            {
                //return ex.Message;
                return "Lưu nháp không thành công";
            }
        }
Example #2
0
        public string ClearDraft(FormDataCollection form)
        {
            try
            {
                var employeeTypeType = (EmployeeType)form.Get("employeeTypeId").ToInt32();
                ContactRepository.ContactUpdateClearDraft(employeeTypeType);

                // Update Account Draft
                var account = new UserDraftInfo
                {
                    IsDraftConsultant = false,
                    IsDraftCollabortor = false,
                    CreatedDate = DateTime.Now,
                    BranchId = UserContext.GetDefaultBranch(),
                    UserId = UserContext.GetCurrentUser().UserID,
                };
                UserDraftRepository.Update(account);

                // Return
                return "Xóa draft thành công";
            }
            catch
            {
                return "Xóa draft không thành công";
            }
        }
Example #3
0
        public int Handover(FormDataCollection form)
        {
            var branchId = UserContext.GetDefaultBranch();
            var productSellId = form.Get("productSellId").ToInt32();
            var createdBy = UserRepository.GetCurrentUserInfo().UserID;
            var datetime = form.Get("datetime").ToDateTime() ?? DateTime.Now;
            var employeeTypeType = (EmployeeType)form.Get("employeeTypeId").ToInt32();

            // Params
            const int statusMapId = 1;
            const int statusCareId = 1;
            var appointmentDate = datetime;
            var handoverDate = datetime.Date;
            const int levelId = (int)LevelType.L1;

            var statusId = 0;
            switch (employeeTypeType)
            {
                case EmployeeType.Collaborator:
                    statusId = (int)StatusType.HandoverCollaborator;
                    break;
                case EmployeeType.Consultant:
                    statusId = (int)StatusType.HandoverConsultant;
                    break;
            }

            // Handover
            var count = ContactRepository.ContactUpdateHandover(branchId, levelId, statusId, statusMapId, statusCareId, productSellId, handoverDate, appointmentDate, createdBy, employeeTypeType);

            // Update Account Draft
            var account = new UserDraftInfo
            {
                IsDraftConsultant = false,
                IsDraftCollabortor = false,
                CreatedDate = DateTime.Now,
                BranchId = UserContext.GetDefaultBranch(),
                UserId = UserContext.GetCurrentUser().UserID,
            };
            UserDraftRepository.Update(account);

            // Return
            return count;
        }