コード例 #1
0
        public HttpResponseMessage GetAll()
        {
            try
            {
                var doctorViewModel = new DoctorViewModel();
                var user            = UserMatching.IsUserMatch();
                if (user == null)
                {
                    responseDoctor.UnAuthorized();
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, responseDoctor, contentType));
                }

                SqlParameter[] sqlParameters;
                string         parameter = SQLParameters.GetParameters <DoctorViewModel>(doctorViewModel);
                sqlParameters = SQLParameters.GetSQLParameters <DoctorViewModel>(doctorViewModel, "GetAll").ToArray();
                var doctorsList = unitOfWork.GetRepositoryInstance <DoctorViewModel>().ReadStoredProcedure("Doctor_Detail " + parameter, sqlParameters).ToList();
                responseDoctor.Success((new JavaScriptSerializer()).Serialize(doctorsList));
                return(Request.CreateResponse(HttpStatusCode.Accepted, responseDoctor, contentType));
            }
            catch (Exception exception)
            {
                responseDoctor.Exception(exception.Message);
                return(Request.CreateResponse(HttpStatusCode.Conflict, responseDoctor, contentType));
            }
        }
コード例 #2
0
        public async Task <ResponseModel <TokenDto> > CreateTokenByRefreshTokenAsync(string refreshToken)
        {
            var userRefreshToken = await _userRefreshTokenRepository.GetAllByFilter(p => p.Code.Equals(refreshToken)).SingleOrDefaultAsync();

            if (userRefreshToken == null)
            {
                return(ResponseModel <TokenDto> .Fail("Refresh token not found", 404, true));
            }

            var user = await _userManager.FindByIdAsync(userRefreshToken.UserId);

            if (user == null)
            {
                return(ResponseModel <TokenDto> .Fail("User not found", 404, true));
            }

            var tokenDto = _tokenService.CreateToken(user);

            userRefreshToken.Code       = tokenDto.RefreshToken;
            userRefreshToken.Expiration = tokenDto.RefreshTokenExpiration;

            _userRefreshTokenRepository.Update(userRefreshToken);
            await _unitOfWork.SaveChangesAsync();

            return(ResponseModel <TokenDto> .Success(tokenDto, 200));
        }
コード例 #3
0
        public async Task <ResponseStructure> GetAttrsByCat(int catid)
        {
            try
            {
                List <AttributeModel> data = this._context.Attribute.ToList();


                var catsAttrAll = this._context.CategoryAttribute.ToList();

                List <CatAttrRelationModel> catsAttr = catsAttrAll.Where(x => x.X_CatId == catid).ToList();

                List <object> Data = new List <object>();

                foreach (var item in catsAttr)
                {
                    Data.Add(new
                    {
                        A_Title    = data.FirstOrDefault(x => x.A_Id == item.X_AttrId).A_Title,
                        A_Id       = data.FirstOrDefault(x => x.A_Id == item.X_AttrId).A_Id,
                        A_Status   = item.X_Status,
                        relationId = item.X_Id,
                    });
                }
                return(ResponseModel.Success("ATTRIBUTE_LIST_RETURNED", Data));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
コード例 #4
0
        public async Task <ActionResult> GetCategoryLevelOne(int type = 1)//Default load physical
        {
            try
            {
                type = type == 0 ? 1 : type;
                int MAX = 0;
                if (type == 1)
                {
                    MAX = Constants.MAX_CAT_LEVEL;
                }
                else if (type == 2)
                {
                    MAX = Constants.MAX_DIGITAL_CAT_LEVEL;
                }
                else if (type == 3)
                {
                    MAX = Constants.MAX_TRAINING_CAT_LEVEL;
                }
                var getChilds = (List <ProductCategoryModel>)(await this._repository.GetAll()).Data;


                List <ProductCat> result = _mapper.Map <List <ProductCategoryModel>, List <ProductCat> >(getChilds.Where(x => x.PC_ParentId == 0 && x.PC_Type == type).ToList());
                return(new JsonResult(ResponseModel.Success(data: new { Cats = result, Max = MAX })));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public IActionResult Add()
        {
            var application = new Domain.Entity.Application();

            application.Icon = "cloud";
            return(View(ResponseModel.Success(application)));
        }
コード例 #6
0
        public async Task <ResponseStructure> DecreaseWallet(int user, decimal amount)
        {
            try
            {
                UserModel userModel = this._context.Users.FirstOrDefault(x => x.U_Id == user);
                if (userModel.U_Wallet < amount)
                {
                    return(ResponseModel.Error("Account balance is not enough"));
                }
                userModel.U_Wallet = userModel.U_Wallet - amount;
                this._context.Users.Update(userModel);
                await this._context.SaveChangesAsync();

                await this.LogTransaction(new WalletHistoryModel()
                {
                    WH_AdderId         = 0,
                    WH_CustomerId      = user,
                    WH_Amount          = amount,
                    WH_TransactionType = 2,
                    WH_PayType         = 0,
                    WH_PayBankRecip    = ""
                });

                return(ResponseModel.Success("Transaction completed successfully."));
            }
            catch (Exception ex)
            {
                return(ResponseModel.ServerInternalError("Server Internal Error", ex));
            }
        }
コード例 #7
0
        public async Task <ActionResult> LoadProductFeedback()
        {
            try
            {
                var All = await this._betterpricerepository.GetAll();

                List <ProdFeedbackModel>             data   = ((List <ProdFeedbackModel>)(All).Data).OrderByDescending(x => x.Created_At).ToList();
                List <OutModels.Models.ProdFeedback> result = _mapper.Map <List <ProdFeedbackModel>, List <OutModels.Models.ProdFeedback> >(data);
                foreach (var item in result)
                {
                    var prd = await _productrepository.GetById(item.F_ProductId);

                    if (prd != null)
                    {
                        item.F_ProductTitle = prd.P_Title + "--" + prd.P_Code;
                    }
                    else
                    {
                        item.F_ProductTitle = "----";
                    }
                }
                return(new JsonResult(ResponseModel.Success("AMAZINGREQUEST_LIST_RETURNED", result)));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
コード例 #8
0
 public async Task <ResponseStructure> AdminLogin(UserModel um)
 {
     try
     {
         var  getAll  = (List <UserModel>)(await GetAll()).Data;
         var  exists  = getAll.FirstOrDefault(x => x.U_Email == um.U_Email);
         bool truepwd = false;
         if (exists == null || !CryptoJsService.verifyPassword(exists.U_Password, um.U_Password))
         {
             return(ResponseModel.Error("Sorry,we couldn't find an account with that username and password."));
         }
         if (exists.U_Status == 2)
         {
             return(ResponseModel.Error("Your account has been suspened."));
         }
         if (um.U_Role == 1)
         {
             var perms = _context.Permissions.Where(x => x.Perm_Uid == exists.U_Id).ToList();
             foreach (var perm in perms)
             {
                 um.Permissions.Add(perm.Perm_Urlid);
             }
         }
         var token = TokenService.GenerateToken(exists.U_Id, exists.U_Name + " " + exists.U_Family, exists.U_Email);
         um.Token = token;
         return(ResponseModel.Success(data: um));
     }
     catch (Exception ex)
     {
         return(ResponseModel.ServerInternalError(data: ex));
     }
 }
コード例 #9
0
 public async Task <ResponseStructure> UploadAudio(IFormFile file, string fireFlag, string loc)
 {
     try
     {
         string ftype = file.ContentType;
         if ((ftype == "audio/mp3" || ftype == "audio/mpeg"))
         {
             string uploadPath = FileLocMapper.LocateMediaFile(fireFlag, loc);
             //long fsize = file[i].Length;
             string fname    = DateTime.UtcNow.Millisecond + UtilesService.GenerateNewRandom() + "." + System.IO.Path.GetExtension(file.FileName).Substring(1);
             var    filePath = Path.Combine(uploadPath, fname);
             using (var stream = new FileStream(filePath, FileMode.Create))
             {
                 await file.CopyToAsync(stream);
             }
             return(ResponseModel.Success(msg: "فایل صوتی با موفقیت آپلود گردید", data: fname));
         }
         else
         {
             return(ResponseModel.Error("نوع فایل ارسال شده صحیح نمیباشد"));
         }
     }
     catch (Exception e)
     {
         return(ResponseModel.Error("خطای ناشناخته در سیستم رخ داده است" + e.Message));
     }
 }
コード例 #10
0
        public async Task <ResponseStructure> UploadBase64(string data, string loc, string fireFlag, int w = 500, int h = 500)
        {
            try
            {
                string       root       = FileLocMapper.LocateMediaFile(fireFlag, loc);
                var          split      = data.Split(',');
                var          strings    = split[1].Split('-');
                byte[]       imageBytes = Convert.FromBase64String(strings[0]);
                MemoryStream ms         = new MemoryStream(imageBytes, 0, imageBytes.Length);
                ms.Write(imageBytes, 0, imageBytes.Length);
                Image  image    = Image.FromStream(ms, true);
                string fileName = DateTime.UtcNow.Millisecond + UtilesService.RandomDigit(15) + UtilesService.getFileExtByContentType(split[0]);
                using (MemoryStream mOutput = new MemoryStream())
                {
                    image.Save(mOutput, image.RawFormat);
                    using (FileStream fs = File.Create(String.Concat(root, fileName).ToLowerInvariant()))
                        using (BinaryWriter bw = new BinaryWriter(fs))
                            bw.Write(mOutput.ToArray());
                }

                return(ResponseModel.Success(msg: "بارگذاری فایل با موفقیت انجام شد", data: fileName));
            }
            catch (Exception ex)
            {
                return(ResponseModel.Error(msg: "خطایی در بارگذاری فایل رخ داده است.لطفا با پشتیبان سایت تماس بگیرید.", data: ex.Message));
            }
        }
コード例 #11
0
 public async Task <ResponseStructure> uploadDocument(IFormFile file, string fireFlag, string loc)
 {
     try
     {
         string[] allowtype = new string[] { "application/msword", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "text/plain", "application/pdf" };
         string   ftype     = file.ContentType;
         if ((allowtype.Contains(ftype)))
         {
             string uploadPath = FileLocMapper.LocateMediaFile(fireFlag, loc);
             //long fsize = file[i].Length;
             string fname    = DateTime.UtcNow.Millisecond + UtilesService.GenerateNewRandom() + "." + System.IO.Path.GetExtension(file.FileName).Substring(1);
             var    filePath = Path.Combine(uploadPath, fname);
             using (var stream = new FileStream(filePath, FileMode.Create))
             {
                 await file.CopyToAsync(stream);
             }
             return(ResponseModel.Success(msg: "فایل با موفقیت آپلود گردید", data: fname));
         }
         else
         {
             return(ResponseModel.Error("نوع فایل ارسال شده صحیح نمیباشد"));
         }
     }
     catch (Exception e)
     {
         return(ResponseModel.Error("خطای ناشناخته در سیستم رخ داده است" + e.Message));
     }
     return(null);
 }
コード例 #12
0
        public async Task <ResponseStructure> Insert(ProductManualModel entity)
        {
            try
            {
                var exists = _context.ProductManual.FirstOrDefault(x => x.M_ProductId == entity.M_ProductId);
                if (exists != null)
                {
                    exists.M_FileName = entity.M_FileName;
                    exists.M_Status   = entity.M_Status;
                    exists.M_Title    = entity.M_Title;
                    exists.M_Price    = entity.M_Price;
                    exists.Updated_At = DateTime.Now;
                    this._context.ProductManual.Update(entity: entity);
                    await this.CommitAllChanges();

                    return(ResponseModel.Success());
                }
                entity.Created_At = DateTime.Now;
                entity.Updated_At = DateTime.Now;
                await this._context.ProductManual.AddAsync(entity : entity);

                await this.CommitAllChanges();

                return(ResponseModel.Success());
            }
            catch (Exception ex)
            {
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }
コード例 #13
0
        public async Task <ActionResult> LoadOffRequests()
        {
            try
            {
                var           AllReqs = (List <OfflinRequestModel>)(await _offreqrepo.GetAll()).Data;
                List <object> result  = new List <object>();
                Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fa");
                int i = 1;
                foreach (var item in AllReqs.OrderByDescending(x => (DateTime)x.Created_At))
                {
                    var user = await _userrepo.GetById(item.O_User);

                    result.Add(new {
                        id      = item.O_Id,
                        counter = i,
                        user    = (user != null) ? user.U_Name + " " + user.U_Family : "",
                        url     = item.O_Url,
                        detail  = item.O_Details,
                        price   = item.O_Price,
                        deliver = item.O_DeliverDate,
                        reqdate = ((DateTime)item.Created_At).ToString("yyyy/MM/dd HH:mm:ss"),
                        reason  = item.O_Reason,
                        status  = item.O_Status
                    });
                    i++;
                }
                return(new JsonResult(ResponseModel.Success(data: result)));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error", ex);
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }
        public IActionResult Add()
        {
            var application = new SevenTiny.Cloud.MultiTenantPlatform.Core.Entity.Application();

            application.Icon = "cloud";
            return(View(ResponseModel.Success(application)));
        }
コード例 #15
0
 public async Task <ActionResult> GetMaxLevel(int type = 1)//Default Physical
 {
     try
     {
         type = type == 0 ? 1 : type;
         int MAX = 0;
         if (type == 1)
         {
             MAX = Constants.MAX_CAT_LEVEL;
         }
         else if (type == 2)
         {
             MAX = Constants.MAX_DIGITAL_CAT_LEVEL;
         }
         else if (type == 3)
         {
             MAX = Constants.MAX_TRAINING_CAT_LEVEL;
         }
         return(new JsonResult(ResponseModel.Success(data: MAX)));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
コード例 #16
0
        public async Task <ResponseStructure> FreeUpCart(HttpRequest httpRequest, HttpResponse httpResponse)
        {
            try
            {
                StringValues            data;
                FullPropertyBasketModel basket = new FullPropertyBasketModel();
                string cookie;
                if (httpRequest.Cookies.TryGetValue("Cart", out cookie))
                {
                    if (cookie != null)
                    {
                        httpResponse.Cookies.Delete("Cart");
                        string token = Barayand.Common.Services.CryptoJsService.EncryptStringToAES(JsonConvert.SerializeObject(basket));

                        httpResponse.Cookies.Append("Cart", token);
                    }
                }
                return(ResponseModel.Success("Cart free."));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error in free up basket cart", ex);
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }
コード例 #17
0
        public async Task <ResponseStructure> SaveReciptientInfo(HttpRequest httpRequest, HttpResponse httpResponse)
        {
            try
            {
                StringValues data;
                if (!httpRequest.Headers.TryGetValue("ReciptientInfo", out data))
                {
                    return(ResponseModel.Error("Invalid access detect."));
                }
                var dec = Barayand.Common.Services.CryptoJsService.DecryptStringAES(data);
                ReciptientInfoModel     rm     = JsonConvert.DeserializeObject <ReciptientInfoModel>(dec);
                FullPropertyBasketModel basket = new FullPropertyBasketModel();
                string cookie;
                if (httpRequest.Cookies.TryGetValue("Cart", out cookie))
                {
                    if (cookie != null)
                    {
                        var basketInfo = Barayand.Common.Services.CryptoJsService.DecryptStringAES(cookie);
                        basket = JsonConvert.DeserializeObject <FullPropertyBasketModel>(basketInfo);
                        basket.RecipientInfo = rm;
                    }
                }

                string token = Barayand.Common.Services.CryptoJsService.EncryptStringToAES(JsonConvert.SerializeObject(basket));
                httpResponse.Cookies.Delete("Cart");
                httpResponse.Cookies.Append("Cart", token);
                return(ResponseModel.Success("اطلاعات دریافت کننده سفارش با موفقیت ذخیره گردید."));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error in adding reciver info to customer basket", ex);
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }
コード例 #18
0
        public async Task <ActionResult> Login(UserModel um)
        {
            try
            {
                um.U_Role = 1;
                var login = await _userrepo.AdminLogin(um);

                if (!login.Status)
                {
                    return(new JsonResult(login));
                }
                var token = ((UserModel)login.Data).Token;
                Response.Cookies.Append("BarayandCPUser", token);
                return(new JsonResult(ResponseModel.Success("Login successfull.", new
                {
                    un = ((UserModel)login.Data).U_Name,
                    uln = ((UserModel)login.Data).U_Family,
                    ue = ((UserModel)login.Data).U_Email,
                    up = ((UserModel)login.Data).U_Phone,
                    ua = ((UserModel)login.Data).U_Avatar,
                    uid = ((UserModel)login.Data).U_Id,
                    perms = ((UserModel)login.Data).Permissions
                })));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error in user login", ex);
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }
コード例 #19
0
        public async Task <IActionResult> CompareSerch(string title, int cat2, int?brand)
        {
            try
            {
                if (cat2 > 0)
                {
                    var getAllProductByCatId = ((List <ProductModel>)(await _productrepo.GetAll()).Data).Where(x => x.P_EndLevelCatId == cat2).ToList();

                    if (!string.IsNullOrEmpty(title))
                    {
                        getAllProductByCatId = getAllProductByCatId.Where(x => x.P_Title.Contains(title, StringComparison.InvariantCultureIgnoreCase)).ToList();
                    }
                    if (brand != null && brand > 0)
                    {
                        getAllProductByCatId = getAllProductByCatId.Where(x => x.P_BrandId == brand).ToList();
                    }

                    var model = await _viewRenderer.RenderAsync(this, "_productlist", getAllProductByCatId);



                    return(new JsonResult(ResponseModel.Success(data: model)));
                }
                return(new JsonResult(ResponseModel.ServerInternalError(data: "error")));
            }


            catch (Exception ex)
            {
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }
コード例 #20
0
        public async Task <ActionResult> ReduceWallet(UserModel um)
        {
            try
            {
                var user = await _userrepo.GetById(um.U_Id);

                if (user == null)
                {
                    return(new JsonResult(ResponseModel.Error("کاربر یافت نشد")));
                }
                var doTransaction = await _walletrepo.DecreaseWallet(user.U_Id, um.U_Wallet);

                if (doTransaction.Status)
                {
                    if (user.U_Phone != null && user.U_Phone != "")
                    {
                        await _smsService.WalletAllert(user.U_Phone, 2, um.U_Wallet.ToString("#,#"));
                    }
                    return(new JsonResult(ResponseModel.Success("عملیات با موفقیت انجام گردید")));
                }
                else
                {
                    return(new JsonResult(doTransaction));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Erro in user controller", ex);
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }
コード例 #21
0
ファイル: PCRepository.cs プロジェクト: hoseinosaty/Homekito
        public async Task <ResponseStructure> GetAll()
        {
            try
            {
                List <ProductCategoryModel> data = this._context.ProductCategory.Where(x => x.PC_IsDeleted == false).ToList();
                foreach (var item in data)
                {
                    string ParentTitle = "****";
                    int    lvl         = 1;
                    if (item.PC_ParentId != 0)
                    {
                        var parent = await this.GetById(item.PC_ParentId);

                        ParentTitle = parent.PC_Title;
                        lvl         = await this.GetCategoryLevel(item.PC_Id);
                    }
                    data.FirstOrDefault(x => x.PC_Id == item.PC_Id).PC_ParentTitle = ParentTitle;
                    data.FirstOrDefault(x => x.PC_Id == item.PC_Id).PC_Level       = lvl;
                    if (lvl == Constants.MAX_CAT_LEVEL || lvl == (Constants.MAX_CAT_LEVEL - 1))
                    {
                        data.FirstOrDefault(x => x.PC_Id == item.PC_Id).PC_AttrAble = true;
                    }
                }
                data = data.OrderBy(x => x.PC_Level).ToList();

                return(ResponseModel.Success(data: data));
            }
            catch (Exception ex)
            {
                return(ResponseModel.Error(msg: ex.Message, data: ex));
            }
        }
コード例 #22
0
 public async Task <ActionResult> LoadUserWalletHistory(UserModel um)
 {
     try
     {
         var allHistories = (List <WalletHistoryModel>)(await _walletrepo.GetAll()).Data;
         allHistories = allHistories.Where(x => x.WH_CustomerId == um.U_Id).ToList();
         List <object> result = new List <object>();
         int           i      = 1;
         foreach (var item in allHistories)
         {
             result.Add(new
             {
                 counter = i,
                 amount  = item.WH_Amount,
                 type    = item.WH_TransactionType == 1 ? "واریز" : "برداشت",
                 user    = item.WH_AdderId == 0 ? "مدیر سیستم" : "کاربر",
                 date    = ((DateTime)item.Created_At).ToString("yyyy/MM/dd HH:mm:ss")
             });
             i++;
         }
         return(new JsonResult(ResponseModel.Success("Wallet history returned", result)));
     }
     catch (Exception ex)
     {
         return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
     }
 }
コード例 #23
0
        public async Task <ResponseStructure> RechargeWallet(int user, decimal amount, string recieptInfo = "")
        {
            try
            {
                UserModel userModel = this._context.Users.FirstOrDefault(x => x.U_Id == user);
                if (amount == 0)
                {
                    return(ResponseModel.Error("Cannot increase zero amount"));
                }
                userModel.U_Wallet = userModel.U_Wallet + amount;
                this._context.Users.Update(userModel);
                await this._context.SaveChangesAsync();

                await this.LogTransaction(new WalletHistoryModel()
                {
                    WH_AdderId         = 0,
                    WH_CustomerId      = user,
                    WH_Amount          = amount,
                    WH_TransactionType = 1,
                    WH_PayType         = 0,
                    WH_PayBankRecip    = recieptInfo
                });

                return(ResponseModel.Success("Transaction completed successfully."));
            }
            catch (Exception ex)
            {
                return(ResponseModel.ServerInternalError("Server Internal Error", ex));
            }
        }
コード例 #24
0
ファイル: ReportService.cs プロジェクト: hoseinosaty/Homekito
 public async Task <object> LastOrders()
 {
     try
     {
         List <object> Items      = new List <object>();
         var           LastOrders = _context.Invoice.OrderByDescending(x => x.ID).Take(10).ToList();
         Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fa-IR");
         foreach (var invoice in LastOrders)
         {
             var    user     = _context.Users.FirstOrDefault(x => x.U_Id == invoice.I_UserId);
             string userInfo = user != null ? user.U_Name + " " + user.U_Family : "ناشناس";
             object item     = new {
                 orderNumber   = invoice.I_Id,
                 orderDate     = (((DateTime)invoice.Created_At).ToString("yyyy/MM/dd ساعت HH:mm:ss")),
                 orderCustomer = userInfo,
                 orderSum      = invoice.I_TotalAmount.ToString("#,#"),
                 orderState    = invoice.I_Status
             };
             Items.Add(item);
         }
         return(ResponseModel.Success(data: Items));
     }
     catch (Exception ex)
     {
         return(ResponseModel.ServerInternalError(data: ex));
     }
 }
コード例 #25
0
        public async Task <ResponseStructure> Insert(DynamicPagesContent entity)
        {
            try
            {
                var All = await this.GetAllInside();

                bool exists = All.Any(x => x.PageName == entity.PageName && x.Lang == entity.Lang);
                if (exists)
                {
                    entity.D_Id = All.FirstOrDefault(x => x.PageName == entity.PageName).D_Id;
                    return(await this.Update(entity));
                }
                else
                {
                    await this._context.DynamicPagesContent.AddAsync(entity : entity);

                    await this.CommitAllChanges();

                    return(ResponseModel.Success("operation successfully completed"));
                }
            }
            catch (Exception ex)
            {
                return(ResponseModel.Error(msg: ex.Message, data: ex));
            }
        }
コード例 #26
0
ファイル: ReportService.cs プロジェクト: hoseinosaty/Homekito
        public async Task <object> SaleByCategories()
        {
            try
            {
                var LastOrders    = _context.Order.ToList();
                var AllCategories = _context.ProductCategory.Where(x => x.PC_ParentId == 0 && x.PC_IsDeleted != true && x.PC_Status).ToList();
                int CountOrders   = LastOrders.Sum(x => x.O_Quantity);
                Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fa-IR");
                List <object> Labels = new List <object>();
                List <object> Series = new List <object>();
                foreach (var category in AllCategories)
                {
                    var products = _context.Product.Where(x => x.P_MainCatId == category.PC_Id).ToList();

                    int count = 0;
                    foreach (var product in products)
                    {
                        var order    = LastOrders.Where(x => x.O_ProductId == product.P_Id).ToList();
                        int quantity = order.Sum(x => x.O_Quantity);

                        count += quantity;
                    }
                    Labels.Add(category.PC_Title);
                    Series.Add(count);
                }
                return(ResponseModel.Success(data: new { labels = Labels, series = Series }));
            }
            catch (Exception ex)
            {
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }
コード例 #27
0
        public async Task <ResponseStructure> UpdateRelation(List <GiftProductModel> data, int prodid)
        {
            try
            {
                if (data.Count() > 1)
                {
                    return(ResponseModel.Error("به هر محصول فقط میتوان یک هدیه نسبت داد"));
                }

                var rel = this._context.GiftProduct.ToList();
                this._context.GiftProduct.RemoveRange(rel.Where(x => x.X_MainProdId == prodid).ToList());
                await this.CommitAllChanges();

                if (data == null || data.Count() == 1)
                {
                    await this._context.GiftProduct.AddRangeAsync(data);

                    await this.CommitAllChanges();
                }

                return(ResponseModel.Success("عملیات با موفقیت انجام گردید"));
            }
            catch (Exception ex)
            {
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }
コード例 #28
0
ファイル: ReportService.cs プロジェクト: hoseinosaty/Homekito
        public async Task <object> TodayIncome()
        {
            try
            {
                DateTime today           = DateTime.Now;
                var      allInvoices     = _context.Invoice.Where(x => ((DateTime)x.Created_At).Day == today.Day).ToList();
                decimal  Total           = allInvoices.Sum(x => x.I_TotalAmount);
                decimal  yesterdayIncome = await this.TodayIncome(today.AddDays(-1));

                if (yesterdayIncome == 0)
                {
                    yesterdayIncome = 0.1M;
                }
                var perc = this.PercentChangeBetweenTwoNumber(yesterdayIncome, Total);
                if (perc > 1000)
                {
                    perc = 1000;
                }
                return(ResponseModel.Success(data: new { change = perc, income = (Total != 0) ? Total.ToString("#,#") : "0", value = new decimal[] { yesterdayIncome, Total } }));
            }
            catch (Exception ex)
            {
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }
コード例 #29
0
        public IActionResult Add()
        {
            var entity = new Menue();

            entity.Icon = "reorder";
            return(View(ResponseModel.Success(entity)));
        }
コード例 #30
0
        public async Task <ResponseStructure> Insert(PromotionBoxModel entity)
        {
            try
            {
                var checkExists = await GetBySectionId(entity.B_SectionId);

                if (checkExists != null)
                {
                    checkExists.B_LoadType  = entity.B_LoadType;
                    checkExists.B_Link      = entity.B_Link;
                    checkExists.B_Image     = entity.B_Image;
                    checkExists.B_Seo       = entity.B_Seo;
                    checkExists.B_Title     = entity.B_Title;
                    checkExists.B_Type      = entity.B_Type;
                    checkExists.B_ColorCode = entity.B_ColorCode;
                    checkExists.B_EntityId  = entity.B_EntityId;
                    checkExists.Updated_At  = DateTime.Now;
                    return(await this.Update(checkExists));
                }
                else
                {
                    this._context.PromotionBoxs.Add(entity);
                    await this._context.SaveChangesAsync();

                    return(ResponseModel.Success("باکس مورد نظر با موفقیت بروزرسانی گردید"));
                }
            }
            catch (Exception ex)
            {
                return(ResponseModel.ServerInternalError(data: ex));
            }
        }