Beispiel #1
0
        private string ValidateEntity(SellerDTO seller)
        {
            if (seller == null)
            {
                return("Null seller");
            }
            if (String.IsNullOrEmpty(seller.Nit) || seller.Nit.Length < 5 || seller.Nit.Length > 20)
            {
                return("Invalid NIT");
            }
            if (String.IsNullOrEmpty(seller.FullName) || seller.FullName.Length > 200)
            {
                return("Invalid fullname");
            }
            if (String.IsNullOrEmpty(seller.Phone) || seller.Phone.Length > 20)
            {
                return("Invalid phone");
            }
            if (String.IsNullOrEmpty(seller.SellerAddress) || seller.SellerAddress.Length > 200)
            {
                return("Invalid address");
            }
            if (seller.RolID <= 0)
            {
                return("Invalid rol");
            }
            if (seller.PenaltyPercentage < 0 || seller.PenaltyPercentage > 100)
            {
                return("Invalid penalty percentage");
            }

            return(OK);
        }
        public async Task <Tuple <string, object> > GetSellerAsync(Guid UserId)
        {
            try
            {
                var seller = await _context.Sellers.Where(x => x.UserId == UserId).Include(x =>
                                                                                           x.User).FirstOrDefaultAsync();

                SellerDTO newObj = new SellerDTO
                {
                    FirstName   = seller.FirstName,
                    LastName    = seller.LastName,
                    PhoneNumber = seller.PhoneNumber,
                    Email       = seller.Email,
                    ShopAddress = seller.Address,
                    CompanyName = seller.CompanyName
                };

                if (newObj == null)
                {
                    return(new Tuple <string, object>(StatusMessage.NOT_FOUND, null));
                }
                return(new Tuple <string, object>(StatusMessage.Ok, newObj));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #3
0
        public SellerDTO GetSellerById(int id)
        {
            using (SqlConnection conn = new SqlConnection(this._connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    conn.Open();
                    SellerDTO seller = new SellerDTO();

                    comm.CommandText = $"select * from Seller where ID={id}";

                    SqlDataReader reader = comm.ExecuteReader();

                    while (reader.Read())
                    {
                        seller = new SellerDTO
                        {
                            ID       = Convert.ToInt32(reader["ID"]),
                            FullName = reader["Name"].ToString(),
                            Mail     = reader["Mail"].ToString(),
                            Login    = reader["Login"].ToString(),
                        };
                    }

                    return(seller);
                }
        }
Beispiel #4
0
        public OperationResult <SellerDTO> Create(SellerDTO seller)
        {
            var validation = ValidateEntity(seller);

            if (validation != OK)
            {
                return(new OperationResult <SellerDTO>(validation, Logger.LogEvent(validation)));
            }
            try
            {
                var rol = new InfoSellers.Repository.RolRepository().ReadById(seller.RolID);
                if (rol == null)
                {
                    return(new OperationResult <SellerDTO>("Specified rol was not found", Logger.LogEvent(validation)));
                }
                var commissionType = new CommissionTypeRepository().ReadById(rol.CommissionTypeID);

                var repository = new InfoSellers.Repository.SellerRepository();

                seller.CurrentCommission = commissionType.CommissionValue;

                var encryptedNIT = SecurityHelper.EncryptString(ENCRYPTION_KEY, seller.Nit);
                seller.Nit = encryptedNIT;
                var newSeller = repository.Create(seller);
                return(new OperationResult <SellerDTO>(seller));
            }
            catch (Exception ex)
            {
                return(new OperationResult <SellerDTO>("Error creating the seller", Logger.LogEvent(ex.Message)));
            }
        }
Beispiel #5
0
 public void InsertSeller(SellerDTO Seller)
 {
     try
     {
         con.Open();
         var para = new DynamicParameters();
         para.Add("@ShopkeeperId", Seller.ShopkeeperId); // Normal Parameters
         para.Add("@ShopName", Seller.ShopName);
         para.Add("@ShopKeeperName", Seller.ShopKeeperName);
         para.Add("@DesignationId", Seller.DesignationId);
         para.Add("@Address", Seller.Address);
         para.Add("@MobileNo", Seller.MobileNo);
         para.Add("@DateofBirth", Seller.DateofBirth);
         para.Add("@StateId", Seller.StateId);
         para.Add("@CityId", Seller.CityId);
         para.Add("@Area", Seller.Area);
         para.Add("@PinCode", Seller.Pincode);
         para.Add("@Email", Seller.Email);
         para.Add("@UserName", Seller.UserName);
         para.Add("@Password", Seller.Password);
         para.Add("@StartDate", Seller.StartDate);
         para.Add("@EndDate", Seller.EndDate);
         para.Add("@CreatedDate", Seller.CreatedDate);
         para.Add("@CreatedBy", Seller.CreatedBy);
         para.Add("@ModifiedDate", Seller.ModifiedDate);
         para.Add("@ModifiedBy", Seller.ModifiedBy);
         para.Add("@DeleteStatus", "ACTIVE");
         var value = con.Query <int>("SP_Insert_Update_Shopkeeper", para, null, true, 0, CommandType.StoredProcedure);
     }
     catch (Exception e) { throw; }
     finally { con.Close(); }
 }
Beispiel #6
0
        public ActionResult SellerChangePassword(SellerDTO obj, FormCollection frm)
        {
            objseller.ChangePassword(obj);
            TempData["MessageRegistration"] = "Data Saved Successfully!";


            return(RedirectToAction("DistributorChangePassword"));
        }
        public async Task <ActionResult <SellerDTO> > CreateSeller(SellerDTO s)
        {
            var s1 = s.toSeller();

            _context.seller.Add(s1);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetSeller), new { id = s1.id }, s1));
        }
 public static string GetAllMessages()
 {
     SellerDTO Sellerinfo = new SellerDTO();
     iSellerProduct ISellerdetails = new SellerProduct();
     var ck = HttpContext.Current.Request.Cookies["Info"].Value;
     string output = ck.Substring(ck.IndexOf('=') + 1);
     Sellerinfo.userName = output;
     DataSet _getProductInfo = ISellerdetails._GetAllMessages(Sellerinfo);
     return JsonConvert.SerializeObject(_getProductInfo);
 }
Beispiel #9
0
 private void butSave_Click(object sender, EventArgs e)
 {
     if (cBSellers.Enabled == true)
     {
         SellerDTO seller = MainForm.DB.Sellers.Get((cBSellers.SelectedItem as SellerDTO).Id);
         seller.NameCompany          = tBNameCompany.Text;
         seller.FullNameCompany      = tBNameCompanyFull.Text;
         seller.INN                  = tBINN.Text;
         seller.KPP                  = tBKPP.Text;
         seller.OGRN                 = tBOGRN.Text;
         seller.BIK                  = tBBIK.Text;
         seller.AddressCompany       = tBAddress.Text;
         seller.Email                = tBEmail.Text;
         seller.PhoneNumber          = tBPhone.Text;
         seller.PersonalAccount      = tBPersonalAccount.Text;
         seller.BankAccount          = tBBankAccount.Text;
         seller.CorrespondentAccount = tBCorespAccount.Text;
         seller.Bank                 = tBBank.Text;
         seller.NameSeller           = tBNameSeller.Text;
         seller.NameSellerSpec       = tBNameSellerSpec.Text;
         seller.RangSeller           = tBRangSeller.Text;
         MainForm.DB.Sellers.Update(seller);
         MainForm.DB.Save();
         MessageBox.Show("Данные успешно сохранены!");
         InitializeSellers();
     }
     else
     {
         SellerDTO seller = new SellerDTO();
         seller.NameCompany          = tBNameCompany.Text;
         seller.FullNameCompany      = tBNameCompanyFull.Text;
         seller.INN                  = tBINN.Text;
         seller.KPP                  = tBKPP.Text;
         seller.OGRN                 = tBOGRN.Text;
         seller.BIK                  = tBBIK.Text;
         seller.AddressCompany       = tBAddress.Text;
         seller.Email                = tBEmail.Text;
         seller.PhoneNumber          = tBPhone.Text;
         seller.PersonalAccount      = tBPersonalAccount.Text;
         seller.BankAccount          = tBBankAccount.Text;
         seller.CorrespondentAccount = tBCorespAccount.Text;
         seller.Bank                 = tBBank.Text;
         seller.NameSeller           = tBNameSeller.Text;
         seller.NameSellerSpec       = tBNameSellerSpec.Text;
         seller.RangSeller           = tBRangSeller.Text;
         MainForm.DB.Sellers.Create(seller);
         MainForm.DB.Save();
         MessageBox.Show("Поставщик успешно добавлен!");
         cBSellers.Enabled = true;
         butDelete.Enabled = true;
         butAdd.Text       = "Добавить нового поставщика";
         InitializeSellers();
     }
 }
Beispiel #10
0
        private void butDelete_Click(object sender, EventArgs e)
        {
            SellerDTO seller = MainForm.DB.Sellers.Get((cBSellers.SelectedItem as SellerDTO).Id);

            if (MessageBox.Show("Вы уверены что хотите удалить поставщика " + seller.NameCompany + "?", "Удаление поставщика", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                MainForm.DB.Sellers.Delete(seller.Id);
                MainForm.DB.Save();
            }
            InitializeSellers();
        }
Beispiel #11
0
        public ActionResult Create()
        {
            SellerDTO objDT = new SellerDTO();

            objDT.ListState           = BindListState();
            objDT.ListCity            = BindListCity();
            ViewData["SelectedState"] = string.Empty;
            ViewData["SelectedCity"]  = string.Empty;

            return(View(objDT));
        }
Beispiel #12
0
        public static string GetAllMessages()
        {
            SellerDTO      Sellerinfo     = new SellerDTO();
            iSellerProduct ISellerdetails = new SellerProduct();
            var            ck             = HttpContext.Current.Request.Cookies["Info"].Value;
            string         output         = ck.Substring(ck.IndexOf('=') + 1);

            Sellerinfo.userName = output;
            DataSet _getProductInfo = ISellerdetails._GetAllMessages(Sellerinfo);

            return(JsonConvert.SerializeObject(_getProductInfo));
        }
Beispiel #13
0
 public static void Mapto9(this Seller s, SellerDTO s1)
 {
     s.id           = s1.id;
     s.phoneNumber  = s1.phoneNumber;
     s.name         = s1.name;
     s.email        = s1.email;
     s.password     = s1.password;
     s.secretKey    = s1.secretKey;
     s.accessToken  = s1.accessToken;
     s.accessExpire = s1.accessExpire;
     s.refreshToken = s1.refreshToken;
 }
Beispiel #14
0
        public void ChangePassword(SellerDTO seller)
        {
            con.Open();
            var para = new DynamicParameters();

            para.Add("@ShopkeeperId", HttpContext.Current.Session["UserId"]); // Normal Parameters
            para.Add("@Password", seller.NewPassword);

            var value = con.Query <int>("SP_Change_Password_Seller", para, null, true, 0, CommandType.StoredProcedure);

            con.Close();
        }
Beispiel #15
0
        public SellerDTO UpdateSeller(SellerDTO seller)
        {
            Console.WriteLine("Change seller inf0: \n");
            Console.WriteLine("FullName, Mail");
            seller = new SellerDTO
            {
                FullName = Console.ReadLine(),
                Mail     = Console.ReadLine(),
            };


            return(_sellerDAL.UpdateSeller(seller));
        }
        public HttpResponseMessage Put(int id, [FromBody] SellerDTO value)
        {
            var resultado = new Domain.Seller().Update(value);

            if (resultado.SuccessResult)
            {
                return(Request.CreateResponse(System.Net.HttpStatusCode.OK, resultado.Result));
            }
            else
            {
                return(Request.CreateResponse(System.Net.HttpStatusCode.InternalServerError, $"{resultado.ErrorID}: {resultado.ErrorDescription}"));
            }
        }
Beispiel #17
0
        public void ChangePasswordAPI(SellerDTO seller)
        {
            try
            {
                con.Open();
                var para = new DynamicParameters();
                para.Add("@ShopkeeperId", seller.ShopkeeperId); // Normal Parameters
                para.Add("@Password", seller.Password);

                var value = con.Query <int>("SP_Change_Password_Distributor", para, null, true, 0, CommandType.StoredProcedure);
            }
            catch (Exception e) { throw; }
            finally { con.Close(); }
        }
Beispiel #18
0
 public static Seller toSeller(this SellerDTO s1)
 {
     return(new Seller()
     {
         id = s1.id,
         phoneNumber = s1.phoneNumber,
         name = s1.name,
         email = s1.email,
         password = s1.password,
         secretKey = s1.secretKey,
         accessToken = s1.accessToken,
         accessExpire = s1.accessExpire,
         refreshToken = s1.refreshToken
     });
 }
Beispiel #19
0
        public SellerDTO AddSeller(SellerDTO seller)
        {
            Console.WriteLine("Enter Full Name, Mail, Login, Password");
            seller = new SellerDTO
            {
                FullName = Console.ReadLine(),
                Mail     = Console.ReadLine(),
                Login    = Console.ReadLine(),
                Password = Convert.ToByte(Console.ReadLine())
            };



            return(_sellerDAL.CreateSeller(seller));
        }
        public async Task <OperationDetails> CreateSeller(SellerDTO sellerDTO)
        {
            OperationDetails details = await CreateBaseUser(sellerDTO as UserDTO);

            if (details.Succeeded == true)
            {
                string userId = details.Message;
                Seller seller = new Seller { /*Specific implementation*/
                };
                UOW.Sellers.Create(seller);
            }
            await UOW.SaveAsync();

            return(new OperationDetails(true, "Реєстрація продавця успішно завершена", ""));
        }
Beispiel #21
0
        public OperationResult <SellerDTO> Update(SellerDTO seller)
        {
            var validation = ValidateEntity(seller);

            if (validation != OK)
            {
                return(new OperationResult <SellerDTO>(validation, Logger.LogEvent(validation)));
            }
            if (seller.ID <= 0)
            {
                return(new OperationResult <SellerDTO>("Invalid ID", Logger.LogEvent(validation)));
            }
            try
            {
                var repository = new InfoSellers.Repository.SellerRepository();
                var dbSeller   = repository.ReadById(seller.ID);
                if (dbSeller == null)
                {
                    return(new OperationResult <SellerDTO>("ID specified was not found", Logger.LogEvent(validation)));
                }
                seller.PenaltyPercentage = dbSeller.PenaltyPercentage; //This value cannot change
                var rol = new InfoSellers.Repository.RolRepository().ReadById(seller.RolID);
                if (rol == null)
                {
                    return(new OperationResult <SellerDTO>("Specified rol was not found", Logger.LogEvent(validation)));
                }
                var commissionType = new CommissionTypeRepository().ReadById(rol.CommissionTypeID);
                seller.CurrentCommission = commissionType.CommissionValue;
                if (seller.Active != dbSeller.Active)
                {
                    if (!seller.Active) //Deactivating seller...
                    {
                        seller.CurrentCommission = commissionType.CommissionValue - (commissionType.CommissionValue * (dbSeller.PenaltyPercentage / 100));
                    }
                }

                var encryptedNIT = SecurityHelper.EncryptString(ENCRYPTION_KEY, seller.Nit);
                seller.Nit = encryptedNIT;

                var updatedSeller = repository.Update(seller);
                return(new OperationResult <SellerDTO>(updatedSeller));
            }
            catch (Exception ex)
            {
                return(new OperationResult <SellerDTO>("Error updating the seller", Logger.LogEvent(ex.Message)));
            }
        }
Beispiel #22
0
        public SellerDTO CreateSeller(SellerDTO seller)
        {
            using (SqlConnection conn = new SqlConnection(this._connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = "insert into Seller (FullName, Mail, Login,Password)  values (@FullName, @Mail, @Login, @Password)";
                    comm.Parameters.Clear();
                    comm.Parameters.AddWithValue("@FullName", seller.FullName);
                    comm.Parameters.AddWithValue("@Mail", seller.Mail);
                    comm.Parameters.AddWithValue("@Login", seller.Login);
                    comm.Parameters.AddWithValue("@Password", seller.Password);

                    conn.Open();

                    seller.ID = Convert.ToInt32(comm.ExecuteScalar());
                    return(seller);
                }
        }
Beispiel #23
0
        public SellerDTO UpdateSeller(SellerDTO seller)
        {
            using (SqlConnection conn = new SqlConnection(this._connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = "update Seller set FullName= @FullName, Mail=@Mail where ID = @ID";
                    comm.Parameters.Clear();
                    comm.Parameters.AddWithValue("@ID", seller.ID);
                    comm.Parameters.AddWithValue("@FullName", seller.FullName);
                    comm.Parameters.AddWithValue("@Mail", seller.Mail);
                    conn.Open();

                    seller.ID = Convert.ToInt32(comm.ExecuteScalar());


                    return(seller);
                }
        }
        public async Task <IActionResult> Updateseller(SellerDTO s)
        {
            var s1 = await _context.seller.FindAsync(s.id);

            if (s1 == null)
            {
                return(NotFound());
            }
            s1.Mapto9(s);
            _context.seller.Update(s1);
            try{
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!SelExist(s1.id))
            {
                return(NotFound());
            }
            return(NoContent());
        }
Beispiel #25
0
        public ActionResult Create(SellerDTO obj, FormCollection frm)
        {
            try
            {
                if (string.IsNullOrEmpty(Convert.ToString(obj.StateId)))
                {
                    ModelState.AddModelError("Error", "Please Select State");
                }

                else if (string.IsNullOrEmpty(Convert.ToString(obj.CityId)))
                {
                    ModelState.AddModelError("Error", "Please Select City");
                }

                else
                {
                    obj.ShopkeeperId = 0;
                    obj.CreatedBy    = Convert.ToInt32(Session["UserID"]);

                    DateTime     timeUtc = System.DateTime.UtcNow;
                    TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
                    DateTime     cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone);
                    obj.CreatedDate = cstTime;


                    objseller.InsertSeller(obj);
                    TempData["MessageRegistration"] = "Data Saved Successfully!";
                    return(RedirectToAction("Create"));
                }
                obj.ListState             = BindListState();
                obj.ListCity              = BindListCity();
                ViewData["SelectedState"] = obj.StateId;
                ViewData["SelectedCity"]  = obj.CityId;
                return(View(obj));
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #26
0
        private void cBSellers_SelectedIndexChanged(object sender, EventArgs e)
        {
            butDelete.Enabled = true;
            SellerDTO selectedSeller = (cBSellers.SelectedItem as SellerDTO);

            tBNameCompany.Text     = selectedSeller.NameCompany;
            tBNameCompanyFull.Text = selectedSeller.FullNameCompany;
            tBINN.Text             = selectedSeller.INN;
            tBKPP.Text             = selectedSeller.KPP;
            tBBIK.Text             = selectedSeller.BIK;
            tBOGRN.Text            = selectedSeller.OGRN;
            tBAddress.Text         = selectedSeller.AddressCompany;
            tBEmail.Text           = selectedSeller.Email;
            tBPhone.Text           = selectedSeller.PhoneNumber;
            tBPersonalAccount.Text = selectedSeller.PersonalAccount;
            tBBankAccount.Text     = selectedSeller.BankAccount;
            tBCorespAccount.Text   = selectedSeller.CorrespondentAccount;
            tBBank.Text            = selectedSeller.Bank;
            tBNameSeller.Text      = selectedSeller.NameSeller;
            tBNameSellerSpec.Text  = selectedSeller.NameSellerSpec;
            tBRangSeller.Text      = selectedSeller.RangSeller;
        }
        public async Task AddSeller()
        {
            var seller = new SellerDTO
            {
                Name = "Micky Mouse"
            };

            var json = JsonConvert.SerializeObject(seller);

            var handleRequest = await httpClient.PostAsync("http://localhost:50555/api/Seller",
                                                           new StringContent(json, Encoding.UTF8, "application/json"));

            Assert.True(handleRequest.StatusCode == System.Net.HttpStatusCode.Created);

            var response = await httpClient.GetAsync("http://localhost:50555/api/Seller");

            var jsonContent = response.Content.ReadAsStringAsync().Result;
            var result      = JsonConvert.DeserializeObject <List <SellerDTO> >(jsonContent);

            Assert.True(response.StatusCode == System.Net.HttpStatusCode.OK);
            Assert.AreEqual(3, result.Count);
            Assert.AreEqual("Micky Mouse", result[1].Name);
        }
Beispiel #28
0
        public ActionResult Edit(SellerDTO obj, FormCollection collection, string actionType)
        {
            if (actionType == "Update")
            {
                if (string.IsNullOrEmpty(Convert.ToString(obj.StateId)))
                {
                    ModelState.AddModelError("Error", "Please Select State");
                }
                else if (string.IsNullOrEmpty(Convert.ToString(obj.CityId)))
                {
                    ModelState.AddModelError("Error", "Please Select City");
                }

                else
                {
                    obj.ModifiedBy = Convert.ToInt32(Session["UserID"]);
                    DateTime     timeUtc = System.DateTime.UtcNow;
                    TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
                    DateTime     cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone);
                    obj.ModifiedDate = cstTime;

                    objseller.UpdateSeller(obj);
                    TempData["MessageUpdate"] = "Distributor Details Updated Successfully.";
                    return(RedirectToAction("Details"));


                    //  return RedirectToAction("Details");
                }

                return(RedirectToAction("Details"));
            }
            else
            {
                return(RedirectToAction("Details"));
            }
        }
Beispiel #29
0
        public ActionResult SellerChangePassword()
        {
            SellerDTO objDT = new SellerDTO();

            return(View(objDT));
        }