Esempio n. 1
0
        private async Task <string> CreateCodeSaze(int organId)
        {
            var count = 0;
            //  GoroheSazeRule goroheSazeRule = new GoroheSazeRule();
            // var goroheSazelst = await goroheSazeRule.GetAllByOrganIdAsync(organId);

            SazeRule sazeRule = new SazeRule();
            var      list     = await sazeRule.GetAllByPersonIdAsync(Convert.ToInt32(organId));

            var saze = list.OrderByDescending(x => x.ID).FirstOrDefault();

            if (saze != null)
            {
                count = Convert.ToInt32(saze.Code);
            }
            //foreach (var goroheSaze in goroheSazelst ?? new List<GoroheSazeVM>())
            //{
            //    if(goroheSaze.Items != null && goroheSaze.Items.Any())
            //        count += goroheSaze.Items.Count();
            //}

            string code = "";

            count++;
            if (count < 10)
            {
                code = "00000" + count;
            }
            else if (count < 100)
            {
                code = "0000" + count;
            }
            else if (count < 1000)
            {
                code = "000" + count;
            }
            else if (count < 10000)
            {
                code = "00" + count;
            }
            else if (count < 100000)
            {
                code = "0" + count;
            }
            else
            {
                code = count.ToString();
            }

            return(code);
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> GetAllByOrganId()
        {
            try
            {
                var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

                SazeRule sazeRule = new SazeRule();
                var      list     = await sazeRule.GetAllByPersonIdAsync(Convert.ToInt32(organId));

                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = ZhivarEnums.ResultCode.Successful, data = list }));
            }
            catch (Exception ex)
            {
                throw;
            }
        }