示例#1
0
        public virtual async Task <HttpResponseMessage> Post(VahedTolVM vahedTolVM)
        {
            var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)ZhivarEnums.ResultCode.Exception, data = "" }));
            }


            var vahedTol = new VahedTol();

            Mapper.Map(vahedTolVM, vahedTol);
            VahedTolRule vahedTolRule = new VahedTolRule();

            vahedTolRule.Insert(vahedTol);

            vahedTol.OrganId = organId;

            await Rule.SaveChangesAsync();

            var afetrGoroheKala = new VahedTol();

            afetrGoroheKala.OrganId = vahedTol.OrganId;
            afetrGoroheKala.Title   = vahedTol.Title;
            // گرید آی دی جدید را به این صورت دریافت می‌کند

            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)ZhivarEnums.ResultCode.Exception, data = afetrGoroheKala }));
        }
示例#2
0
        public virtual async Task <HttpResponseMessage> GetAllByOrganId()
        {
            try
            {
                var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

                VahedTolRule vahedTolRule = new VahedTolRule();
                var          list         = await vahedTolRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                var list2 = list.Select(x => new { FamilyTree = "کالاها و خدمات", Id = x.ID, Title = x.Title, Parents = ",2,", SystemAccount = 2 }).ToList();

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