示例#1
0
        public LongResult UploadSellerDocument(long documentId)
        {
            try
            {
                var userId = ClaimPrincipalFactory.GetUserId(User);
                var seller = _repository.Seller.FindByCondition(c => c.UserId == userId).FirstOrDefault();
                if (seller == null)
                {
                    return(LongResult.GetFailResult("فروشنده پیدا نشد!"));
                }


                var documentfile = HttpContext.Request.Form.Files.GetFile("Document");
                if (documentfile != null)
                {
                    var docpath          = "";
                    var uploadFileStatus = FileManeger.FileUploader(documentfile, 1, "SellerDocuments");
                    if (uploadFileStatus.Status == 200)
                    {
                        docpath = uploadFileStatus.Path;
                    }
                    else
                    {
                        return(LongResult.GetFailResult(uploadFileStatus.Path));
                    }

                    SellerDocument doc = new SellerDocument
                    {
                        FileUrl    = docpath,
                        SellerId   = seller.Id,
                        CuserId    = userId,
                        Cdate      = DateTime.Now.Ticks,
                        DocumentId = documentId
                    };
                    _repository.SellerDocument.Create(doc);
                    _repository.Save();

                    return(LongResult.GetSingleSuccessfulResult(doc.Id));
                }

                return(LongResult.GetFailResult("فایلی بارگزاری نشده است"));
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(LongResult.GetFailResult(e.Message));
            }
        }
        public LongResult UpdateSellerFullInfo(SellerRegisterDto input)
        {
            var userId = ClaimPrincipalFactory.GetUserId(User);//10136
            var seller = _repository.Seller.FindByCondition(c => c.UserId == userId).FirstOrDefault();

            if (seller == null)
            {
                var ress = LongResult.GetFailResult("فروشنده پیدا نشد!");
                _logger.LogData(MethodBase.GetCurrentMethod(), ress, null, input);
                return(ress);
            }

            if (input.Mobile == null)
            {
                var ress = LongResult.GetFailResult("شماره موبایل  وارد نشده است");
                _logger.LogData(MethodBase.GetCurrentMethod(), ress, null, input);
                return(ress);
            }

            try
            {
                seller.Mobile           = input.Mobile;
                seller.Email            = input.Email;
                seller.Name             = input.Name;
                seller.MelliCode        = input.MelliCode;
                seller.Fname            = input.Fname;
                seller.MobileAppTypeId  = input.MobileAppTypeId;
                seller.HaveMobileApp    = input.HaveMobileApp;
                seller.RealOrLegal      = input.RealOrLegal;
                seller.SecondMobile     = input.SecondMobile;
                seller.ShabaNo          = input.ShabaNo;
                seller.Tel              = input.Tel;
                seller.SellerCode       = _repository.Seller.FindAll().Max(c => c.SellerCode) + 1;
                seller.Cdate            = DateTime.Now.Ticks;
                seller.Bdate            = DateTimeFunc.MiladiToTimeTick(input.Bdate);
                seller.FinalStatusId    = 14;
                seller.MobileAppVersion = input.MobileAppVersion;
                seller.Gender           = input.Gender;
                seller.IdentityNo       = input.IdentityNo;

                if (!string.IsNullOrWhiteSpace(input.PassWord))
                {
                    var u = _repository.Users.FindByCondition(c => c.Id == userId).FirstOrDefault();
                    u.Hpassword = input.PassWord;
                    _repository.Users.Update(u);
                }

                if (input.Address.ID == 0)
                {
                    var sellerAddress = new SellerAddress
                    {
                        Address    = input.Address.Address,
                        Fax        = input.Address.Fax,
                        CityId     = input.Address.CityId,
                        PostalCode = input.Address.PostalCode,
                        ProvinceId = input.Address.ProvinceId,
                        Tel        = input.Address.Tel,
                        Titel      = input.Address.Titel,
                        Xgps       = input.Address.Xgps,
                        Ygps       = input.Address.Ygps,
                        Cdate      = DateTime.Now.Ticks,
                        SellerId   = seller.Id
                    };
                    _repository.SellerAddress.Create(sellerAddress);
                    _repository.Seller.Update(seller);
                    _repository.Save();
                }
                else
                {
                    var sellerAddress = _repository.SellerAddress.FindByCondition(c => c.Id == input.Address.ID).FirstOrDefault();
                    if (sellerAddress != null)
                    {
                        sellerAddress.Address    = input.Address.Address;
                        sellerAddress.Fax        = input.Address.Fax;
                        sellerAddress.CityId     = input.Address.CityId;
                        sellerAddress.PostalCode = input.Address.PostalCode;
                        sellerAddress.ProvinceId = input.Address.ProvinceId;
                        sellerAddress.Tel        = input.Address.Tel;
                        sellerAddress.Titel      = input.Address.Titel;
                        sellerAddress.Xgps       = input.Address.Xgps;
                        sellerAddress.Ygps       = input.Address.Ygps;
                        sellerAddress.Mdate      = DateTime.Now.Ticks;
                        sellerAddress.MuserId    = ClaimPrincipalFactory.GetUserId(User);
                        _repository.SellerAddress.Update(sellerAddress);
                    }
                    _repository.Seller.Update(seller);
                    _repository.Save();
                }

                var finalres = LongResult.GetSingleSuccessfulResult(seller.Id);
                _logger.LogData(MethodBase.GetCurrentMethod(), finalres, null, input);
                return(finalres);
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), input);
                return(LongResult.GetFailResult("خطا در سامانه"));
            }
        }