public ProgramDetailsModel getCurrentInfo()
        {
            ProgramDetailsModel packs = new ProgramDetailsModel();


            using (incposdbEntities entity = new incposdbEntities())
            {
                packs = (from p in entity.ProgramDetails
                         //  join p in entity.posSetting on S.id equals p.posSerialId
                         select new ProgramDetailsModel
                {
                    programName = p.programName,

                    branchCount = p.branchCount,
                    posCount = p.posCount,
                    userCount = p.userCount,
                    vendorCount = p.vendorCount,
                    customerCount = p.customerCount,
                    itemCount = p.itemCount,
                    saleinvCount = p.saleinvCount,
                    storeCount = p.storeCount,
                    packageSaleCode = p.packageSaleCode,
                    customerServerCode = p.customerServerCode,
                    expireDate = p.expireDate,
                    isOnlineServer = p.isOnlineServer,

                    updateDate = p.updateDate,
                    isLimitDate = (p.isLimitDate == true) ? true : false,


                    isActive = p.isActive,
                    packageName = p.packageName,
                    versionName = p.versionName,
                    packageNumber = p.packageNumber,
                    customerName = p.customerName,
                    customerLastName = p.customerLastName,
                    agentName = p.agentName,
                    agentLastName = p.agentLastName,
                    agentAccountName = p.agentAccountName,
                }).FirstOrDefault();

                packs.posCountNow = entity.pos.Count();

                packs.branchCountNow = entity.branches.Where(x => x.type == "b").Count();

                packs.storeCountNow    = entity.branches.Where(x => x.type == "s").Count();
                packs.userCountNow     = entity.users.Count();
                packs.vendorCountNow   = entity.agents.Where(x => x.type == "v").Count();
                packs.customerCountNow = entity.agents.Where(x => x.type == "c").Count();
                packs.itemCountNow     = entity.items.Count();

                packs.saleinvCountNow = getSalesInvCountInMonth();
                packs.serverDateNow   = DateTime.Now;
            }



            return(packs);
        }
        /// <summary>
        /// Gets the program by identifier.
        /// </summary>
        /// <param name="programID">The program identifier.</param>
        /// <returns></returns>
        public Response <ProgramDetailsModel> GetProgramByID(long programID)
        {
            var programResponse = new Response <ProgramDetailsModel>()
            {
                DataItems  = new List <ProgramDetailsModel>(),
                ResultCode = 0
            };

            var programDetails = new ProgramDetailsModel();

            var program = _organizationStructureDataProvider.GetOrganizationStructureByID(programID);

            if (program.ResultCode != 0)
            {
                programResponse.ResultCode    = program.ResultCode;
                programResponse.ResultMessage = program.ResultMessage;
                return(programResponse);
            }
            else
            {
                programDetails.Program = program.DataItems.FirstOrDefault();
            }

            var programHierarchy = _organizationStructureDataProvider.GetOrganizationHierarchyByID(programID, OrganizationType.Program.ToString());

            if (programHierarchy.ResultCode != 0)
            {
                programResponse.ResultCode    = programHierarchy.ResultCode;
                programResponse.ResultMessage = programHierarchy.ResultMessage;
                return(programResponse);
            }
            else
            {
                programDetails.ProgramHierarchies = programHierarchy.DataItems;
            }

            var divisionHierarchy = _organizationStructureDataProvider.GetOrganizationHierarchyByID(programID, OrganizationType.ProgramUnit.ToString());

            if (divisionHierarchy.ResultCode != 0)
            {
                programResponse.ResultCode    = divisionHierarchy.ResultCode;
                programResponse.ResultMessage = divisionHierarchy.ResultMessage;
                return(programResponse);
            }
            else
            {
                programDetails.DivisionHierarchies = divisionHierarchy.DataItems;
            }

            programResponse.DataItems.Add(programDetails);
            return(programResponse);
        }
        public ProgramDetailsModel getCustomerServerCode()
        {
            ProgramDetailsModel packs = new ProgramDetailsModel();

            using (incposdbEntities entity = new incposdbEntities())
            {
                packs = (from p in entity.ProgramDetails
                         //  join p in entity.posSetting on S.id equals p.posSerialId
                         select new ProgramDetailsModel
                {
                    customerServerCode = p.customerServerCode,
                }).FirstOrDefault();
            }
            return(packs);
        }
        /// <summary>
        /// Save the program.
        /// </summary>
        /// <param name="program">The program.</param>
        /// <returns></returns>
        public Response <ProgramDetailsModel> SaveProgram(ProgramDetailsModel program)
        {
            var programResponse = new Response <ProgramDetailsModel>();

            using (var transactionScope = _unitOfWork.BeginTransactionScope())
            {
                var programResult = new Response <OrganizationDetailsModel>();
                if (program.Program.DetailID > 0)
                {
                    programResult = _organizationStructureDataProvider.UpdateOrganizationStructure(program.Program);
                }
                else
                {
                    program.Program.DataKey  = OrganizationType.Program.ToString();
                    programResult            = _organizationStructureDataProvider.AddOrganizationStructure(program.Program);
                    program.Program.DetailID = programResult.ID;
                }

                program.ProgramHierarchies.ForEach(item =>
                {
                    item.ProgramID = program.Program.DetailID;
                });

                // if program is failed to save
                if (programResult.ResultCode != 0)
                {
                    programResponse.ResultCode    = programResult.ResultCode;
                    programResponse.ResultMessage = programResult.ResultMessage;
                    return(programResponse);
                }

                var programHierarchyResult = _organizationStructureDataProvider.SaveOrganizationHierarchy(program.ProgramHierarchies, OrganizationType.Program.ToString());
                // if program hierarchy is failed to save
                if (programHierarchyResult.ResultCode != 0)
                {
                    programResponse.ResultCode    = programHierarchyResult.ResultCode;
                    programResponse.ResultMessage = programHierarchyResult.ResultMessage;
                    return(programResponse);
                }

                if (!program.ForceRollback.GetValueOrDefault(false))
                {
                    _unitOfWork.TransactionScopeComplete(transactionScope);
                }
            }

            return(programResponse);
        }
        public async Task <string> getCurrentInfo(string token)
        {
            token = TokenManager.readToken(HttpContext.Current.Request);
            var strP = TokenManager.GetPrincipal(token);

            if (strP != "0") //invalid authorization
            {
                return(TokenManager.GenerateToken(strP));
            }
            else
            {
                try
                {
                    ProgramDetailsModel packrow = new ProgramDetailsModel();
                    packrow = getCurrentInfo();

                    return(TokenManager.GenerateToken(packrow));
                }
                catch
                {
                    return(TokenManager.GenerateToken("0"));
                }
            }
        }
 public Response <ProgramDetailsModel> SaveProgram(ProgramDetailsModel program)
 {
     return(_programService.SaveProgram(program));
 }
Exemple #7
0
        /// <summary>
        /// Saves the program.
        /// </summary>
        /// <param name="program">The program.</param>
        /// <returns></returns>
        public Response <ProgramDetailsModel> SaveProgram(ProgramDetailsModel program)
        {
            const string apiUrl = BaseRoute + "SaveProgram";

            return(communicationManager.Post <ProgramDetailsModel, Response <ProgramDetailsModel> >(program, apiUrl));
        }
 /// <summary>
 /// Saves the division.
 /// </summary>
 /// <param name="program">The division.</param>
 /// <returns></returns>
 public Response <ProgramDetailsModel> SaveProgram(ProgramDetailsModel program)
 {
     return(_programRepository.SaveProgram(program));
 }
Exemple #9
0
 public IHttpActionResult SaveProgram(ProgramDetailsModel program)
 {
     return(new HttpResult <Response <ProgramDetailsModel> >(_programRuleEngine.SaveProgram(program), Request));
 }