public ActionResult AddSellerInformation(SellerProfile sellerProfile)
        {
            Client = WebApiHelper.Initial();
            string mID = GenrateMerchantID();

            sellerProfile.MerchantID = Convert.ToInt64(mID) + sellerProfile.UserID;
            HttpResponseMessage _requestMessage = Client.PostAsJsonAsync(GlobalConst.Api.Seller + "AddSellerProfile\\sellerProfile\\", sellerProfile).Result;

            if (_requestMessage.IsSuccessStatusCode)
            {
                sellerProfile.Message = GlobalConst.Message.AddSucessfully;
            }
            BodyBuilder sb = new BodyBuilder();

            sb.HtmlBody = "**THIS IS AN AUTOMATED MESSAGE - PLEASE DO NOT REPLY DIRECTLY TO THIS EMAIL**" + "<br><br>"
                          + "Hi, " + "<br><br>"
                          + "This is Your MerchantID ." + sellerProfile.MerchantID + "<br>"
                          + "<br><br>" + "Thank You,"
                          + "<br><br>" + "Innovate Support Team";
            var message = new MimeMessage();

            message.From.Add(new MailboxAddress("*****@*****.**", "*****@*****.**"));
            message.To.Add(new MailboxAddress(sellerProfile.EmailID, sellerProfile.EmailID));
            message.Subject = "Seller MerchantID";
            message.Body    = sb.ToMessageBody();
            using (var client = new SmtpClient())
            {
                client.Connect("smtp.office365.com", 587, false);
                client.Authenticate("*****@*****.**", "Cuxo9003");
                client.Send(message);
                client.Disconnect(true);
            }
            return(Json(sellerProfile));
        }
Exemplo n.º 2
0
 public void TestUpdateSellerProfile_Success()
 {
     try
     {
         SellerProfile seller1 = new SellerProfile();
         Seller        seller  = new Seller {
             Sellerid = 2, Username = "******", Gst = "6475JH6754", Companyname = "virtusa", Briefaboutcompany = "good"
         };
         seller1.Username          = seller.Username;
         seller1.Password          = seller.Password;
         seller1.Companyname       = seller.Companyname;
         seller1.Briefaboutcompany = seller.Briefaboutcompany;
         seller1.Postaladdress     = seller.Postaladdress;
         seller1.Website           = seller.Website;
         seller1.Emailid           = seller.Emailid;
         seller1.Contactnumber     = seller.Contactnumber;
         var mock = new Mock <ISellerRepository>();
         mock.Setup(x => x.UpdateSellerProfile(seller1)).ReturnsAsync(true);
         //SellerRepository sellerRepository = new SellerRepository(mock.Object);
         var result = SellerRepository.UpdateSellerProfile(seller1);
         Assert.IsNotNull(result, "test method failed SellerRegister method is null");
         //Assert.AreEqual(result, true);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
        public async Task <bool> UpdateSellerProfile(SellerProfile seller)
        {
            Seller seller1 = _context.Seller.Find(seller.Sellerid);

            if (seller != null)
            {
                seller1.Username          = seller.Username;
                seller1.Password          = seller.Password;
                seller1.Companyname       = seller.Companyname;
                seller1.Briefaboutcompany = seller.Briefaboutcompany;
                seller1.Postaladdress     = seller.Postaladdress;
                seller1.Website           = seller.Website;
                seller1.Emailid           = seller.Emailid;
                seller1.Contactnumber     = seller.Contactnumber;
            }
            ;
            _context.Update(seller1);
            var sellerId = await _context.SaveChangesAsync();

            if (sellerId > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public async Task <ActionResult <OwnUserResponse> > GetOwnAsync([FromHeader(Name = "Authorization"), Required] string authorization)
        {
            var validation = Token.ValidateAuthorization(authorization);

            if (!validation.IsValid)
            {
                return(BadRequest(validation.Result));
            }

            var user = await _context.Users.FirstOrDefaultAsync(x => x.Token == validation.Token);

            if (user == null)
            {
                return(Unauthorized());
            }

            var promotionsCount = _context.Promotions.Count(x => x.UserFK == user.Id);
            var orders          = _context.Orders.Include(x => x.Promotion).Where(x => x.Promotion.UserFK == user.Id);
            var votesCount      = orders.Count(x => x.IsVotePositive != null);
            var positiveVotes   = orders.Count(x => x.IsVotePositive == true);

            var sellerProfile = new SellerProfile
            {
                TotalPromotions = promotionsCount,
                TotalOrders     = orders.Count(),
                OrdersUpvotes   = positiveVotes,
                OrdersDownvotes = votesCount - positiveVotes
            };

            return(Ok(new OwnUserResponse {
                Id = user.Id, Nickname = user.Nickname, ImageUrl = user.ImageUrl, RegisterDate = user.RegisterDate, Type = user.Type, Credit = user.Credit, Email = user.Email, Name = user.Name, StateFK = user.StateFK, SellerProfile = sellerProfile
            }));
        }
Exemplo n.º 5
0
        public async Task <ActionResult <IEnumerable <UserResponse> > > GetAsync([FromHeader(Name = "Authorization"), Required] string authorization, [FromRoute, Required] long id)
        {
            var validation = Token.ValidateAuthorization(authorization);

            if (!validation.IsValid)
            {
                return(BadRequest(validation.Result));
            }

            if (!await _context.Users.AnyAsync(x => x.Token == validation.Token))
            {
                return(Unauthorized());
            }

            var user = await _context.Users.FindAsync(id);

            if (user == null)
            {
                return(NotFound(new ErrorResponse {
                    Error = "User not found"
                }));
            }

            var promotionsCount = _context.Promotions.Count(x => x.UserFK == user.Id);
            var orders          = _context.Orders.Include(x => x.Promotion).Where(x => x.Promotion.UserFK == user.Id);
            var votesCount      = orders.Count(x => x.IsVotePositive != null);
            var positiveVotes   = orders.Count(x => x.IsVotePositive == true);

            var sellerProfile = new SellerProfile
            {
                TotalPromotions = promotionsCount,
                TotalOrders     = orders.Count(),
                OrdersUpvotes   = positiveVotes,
                OrdersDownvotes = votesCount - positiveVotes
            };

            return(Ok(new UserResponse
            {
                Id = user.Id,
                Nickname = user.Nickname,
                ImageUrl = user.ImageUrl,
                RegisterDate = user.RegisterDate,
                Type = user.Type,
                SellerProfile = sellerProfile
            }));
        }
 public async Task ViewSellerProfileSuccess(int sellerid)
 {
     try
     {
         SellerProfile seller = new SellerProfile();
         var           mock   = new Mock <ISellerRepository>();
         mock.Setup(x => x.ViewSellerProfile(sellerid)).ReturnsAsync(seller);
         SellerManager sellerManager = new SellerManager(mock.Object);
         var           result        = sellerManager.ViewSellerProfile(sellerid);
         //Assert.AreEqual(true, result);
         Assert.NotNull(result);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
        public async Task ViewSellerProfile_UnSuccessful(int sellerid)
        {
            try
            {
                SellerProfile seller = new SellerProfile();
                var           mock   = new Mock <ISellerRepository>();
                mock.Setup(x => x.ViewSellerProfile(sellerid)).ReturnsAsync(seller);
                SellerManager sellerManager = new SellerManager(mock.Object);
                var           result        = await sellerManager.ViewSellerProfile(sellerid);

                Assert.IsNull(result, "invalid seller");
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Exemplo n.º 8
0
 public void Test_ViewSellerProfile_UnSuccess()
 {
     try
     {
         var seller = new SellerProfile {
             Sellerid = 1, Username = "******", Password = "******"
         };
         var mock = new Mock <ISellerRepository>();
         mock.Setup(x => x.ViewSellerProfile(1)).ReturnsAsync(seller);
         var result = SellerRepository.ViewSellerProfile(1);
         Assert.IsNotNull(result, "test method failed ValidateSeller method is null");
         Assert.AreEqual(mock.Object, result);
     }
     catch (Exception e)
     {
         Assert.Fail(e.InnerException.Message);
     }
 }
        public void AddsellerProfile()
        {
            SellerProfile sellerProfile = new SellerProfile
            {
                BusinessTitle    = "demo333",
                CompanyName      = "demo3242",
                StreetAddress    = "demo3242",
                City             = "demo3242",
                State            = "demo3242",
                Country          = "demo333",
                ZipCode          = "234243",
                PhoneNumber      = "23423423",
                NumberOfProducts = 2,
                MerchantID       = 12345667891,
                UserID           = 15,
            };
            var _id = _sellerRepository.AddSellerProfile(sellerProfile);

            Assert.True(_id > 0, "failed");
        }
        public async Task UpdateSellerProfile_UnSuccess()
        {
            try
            {
                SellerProfile seller = new SellerProfile()
                {
                    Sellerid = 508, Username = "******", Password = "******", Companyname = "accenture", Gst = "78", Briefaboutcompany = "good", Postaladdress = "mumbai", Website = "www.accenture.com", Emailid = "*****@*****.**", Contactnumber = "9478654567"
                };
                var mock = new Mock <ISellerRepository>();
                mock.Setup(x => x.UpdateSellerProfile(seller)).ReturnsAsync(false);
                SellerManager sellerManager = new SellerManager(mock.Object);
                var           result        = await sellerManager.UpdateSellerProfile(seller);

                Assert.AreEqual(false, result);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
        public async Task <SellerProfile> ViewSellerProfile(int sellerid)
        {
            Seller seller = await _context.Seller.FindAsync(sellerid);

            SellerProfile sellerProfile = new SellerProfile();

            if (seller != null)
            {
                sellerProfile.Sellerid          = seller.Sellerid;
                sellerProfile.Username          = seller.Username;
                sellerProfile.Password          = seller.Password;
                sellerProfile.Companyname       = seller.Companyname;
                sellerProfile.Briefaboutcompany = seller.Briefaboutcompany;
                sellerProfile.Postaladdress     = seller.Postaladdress;
                sellerProfile.Website           = seller.Website;
                sellerProfile.Emailid           = seller.Emailid;
                sellerProfile.Contactnumber     = seller.Contactnumber;
            }
            return(sellerProfile);
        }
        public void UpdatesellerProfile()
        {
            SellerProfile sellerProfile = new SellerProfile
            {
                SellerProfileID  = 2,
                BusinessTitle    = "Jassa",
                CompanyName      = "Jassa",
                StreetAddress    = "Jassa",
                City             = "Jassa",
                State            = "Jassa",
                Country          = "Jassa",
                ZipCode          = "Jassa",
                PhoneNumber      = "Jassa",
                NumberOfProducts = 2,
                MerchantID       = 12345667891,
                UserID           = 15,
            };
            var _id = _sellerRepository.UpdateSellerProfile(sellerProfile);

            Assert.True(_id > 0, "failed");
        }
 public async Task <IActionResult> UpdateSellerProfile(SellerProfile seller)
 {
     _logger.LogInformation("EditPROFILE");
     return(Ok(await _iSellerManager.UpdateSellerProfile(seller)));
 }
        public async Task <SellerProfile> ViewSellerProfile(int sellerid)
        {
            SellerProfile seller = await _iSellerRepository.ViewSellerProfile(sellerid);

            return(seller);
        }
        public async Task <bool> UpdateSellerProfile(SellerProfile seller)
        {
            bool user = await _iSellerRepository.UpdateSellerProfile(seller);

            return(user);
        }
 public int UpdateSellerProfile(SellerProfile sellerProfile)
 {
     return(_sellerProfileRepository.Update(sellerProfile));
 }
 public int AddSellerProfile(SellerProfile sellerProfile)
 {
     return(_sellerProfileRepository.Add(sellerProfile).SellerProfileID);
 }
Exemplo n.º 18
0
        public ActionResult UpdateSellerProfile(SellerProfile sellerProfile)
        {
            int sellerProfileID = _sellerRepository.UpdateSellerProfile(_mapper.Map <OnlineStore.Core.Data.Model.SellerProfile>(sellerProfile));

            return(sellerProfileID == 0 ? NotFound(sellerProfileID) : (ActionResult)Ok(sellerProfileID));
        }
Exemplo n.º 19
0
        public IActionResult GetSellerProfileByUserID(int userID)
        {
            SellerProfile sellerProfile = _mapper.Map <SellerProfile>(_sellerRepository.GetSellerProfileByUserID(userID));

            return(sellerProfile == null?NotFound(sellerProfile) : (IActionResult)Ok(sellerProfile));
        }