Example #1
0
        public async Task <IHttpActionResult> PutSalesRep(int id, SalesRep salesRep)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != salesRep.id)
            {
                return(BadRequest());
            }

            db.Entry(salesRep).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SalesRepExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult <SalesRep> > PostSalesRep(SalesRep salesRep)
        {
            _context.SalesReps.Add(salesRep);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSalesRep", new { id = salesRep.RepID }, salesRep));
        }
Example #3
0
        public async Task <IHttpActionResult> DeleteOrder(int id)
        {
            Order order = await db.Orders.FindAsync(id);

            if (order == null)
            {
                return(NotFound());
            }

            //if its a sales rep, check if he/she is the creator otherwise throw an error
            string   reg   = User.Identity.GetUserId();
            SalesRep sales = await db.SalesReps.Where(b => b.userid == reg).SingleOrDefaultAsync();

            if (sales != null)
            {
                if (sales.id != order.id)
                {
                    return(Unauthorized());
                }
            }
            //SalesRep sales1 = await db.SalesReps.FindAsync(order.salesRepId);

            order.status          = "cancelled";
            db.Entry(order).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(Ok());
        }
Example #4
0
        public async Task <IHttpActionResult> PutBranch(int branchId, int salesRepId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Branch branch = await db.Branches.FindAsync(salesRepId);

            SalesRep salesRep = await db.SalesReps.FindAsync(salesRepId);

            if (salesRep == null)
            {
                return(BadRequest("Sales rep does not exist"));
            }


            if (branch == null)
            {
                return(BadRequest("branch does not exist"));
            }

            branch.salesRepId      = salesRepId;
            db.Entry(branch).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> PutSalesRep(int id, SalesRep salesRep)
        {
            if (id != salesRep.RepID)
            {
                return(BadRequest());
            }

            _context.Entry(salesRep).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SalesRepExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #6
0
        public void SaveSettings()
        {
            var xml = new StringBuilder();

            xml.AppendLine(@"<Settings>");
            if (!String.IsNullOrEmpty(SelectedColor))
            {
                xml.AppendLine(@"<SelectedColor>" + SelectedColor.Replace(@"&", "&#38;").Replace("\"", "&quot;") + @"</SelectedColor>");
            }
            xml.AppendLine(@"<UseSlideMaster>" + UseSlideMaster + @"</UseSlideMaster>");
            xml.AppendLine(@"<BroadcastCalendarSettings>" + BroadcastCalendarSettings.Serialize() + @"</BroadcastCalendarSettings>");
            if (!String.IsNullOrEmpty(SalesRep))
            {
                xml.AppendLine(@"<SalesRep>" + SalesRep.Replace(@"&", "&#38;").Replace("\"", "&quot;") + @"</SalesRep>");
            }
            if (!String.IsNullOrEmpty(SelectedStarOutputItemsEncoded))
            {
                xml.AppendLine(@"<SelectedStarOutputItemsEncoded>" + SelectedStarOutputItemsEncoded.Replace(@"&", "&#38;").Replace("\"", "&quot;") + @"</SelectedStarOutputItemsEncoded>");
            }
            if (!String.IsNullOrEmpty(SelectedShiftOutputItemsEncoded))
            {
                xml.AppendLine(@"<SelectedShiftOutputItemsEncoded>" + SelectedShiftOutputItemsEncoded.Replace(@"&", "&#38;").Replace("\"", "&quot;") + @"</SelectedShiftOutputItemsEncoded>");
            }
            xml.AppendLine(@"<ApplyThemeForAllSlideTypes>" + ApplyThemeForAllSlideTypes + @"</ApplyThemeForAllSlideTypes>");
            xml.AppendLine(_themeSaveHelper.Serialize());
            xml.AppendLine(@"</Settings>");
            using (var sw = new StreamWriter(Asa.Common.Core.Configuration.ResourceManager.Instance.AppSettingsFile.LocalPath, false))
            {
                sw.Write(xml);
                sw.Flush();
            }
        }
Example #7
0
        private void ChangeRecMgr_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
        {
            IObjectSpace os = this.ObjectSpace;

            //ArrayList ObjectsToProcess = new ArrayList(e.SelectedObjects);
            if (e.SelectedChoiceActionItem.ParentItem != setSalesRepItem)
            {
                int rc_count = 0;
                foreach (Customer obj in e.SelectedObjects)
                {
                    SalesRep sr = os.FindObject <SalesRep>(new BinaryOperator("SalesRepCode", e.SelectedChoiceActionItem.Data));
                    //Customer objInNewObjectSpace = (Customer)ObjectSpace.GetObject(obj);
                    obj.SalesRep           = sr;
                    obj.SalesRepAssignedDt = DateTime.Now;
                    rc_count++;
                }
                MessageOptions options = new MessageOptions();
                options.Message = string.Format("Record Manager Changed for {0} Customers",
                                                rc_count.ToString("#,###"));
                options.Type         = InformationType.Success;
                options.Web.Position = InformationPosition.Right;
                options.Win.Caption  = "Success";
                options.Win.Type     = WinMessageType.Alert;
                options.Duration     = 10000;
                Application.ShowViewStrategy.ShowMessage(options);
            }
        }
Example #8
0
 //Copy Constructor
 public SalesRep(SalesRep pSalesRep, int pSalesRepID, string pSalesRepAddress)
 {
     SalesRepID      = pSalesRepID;
     SalesRepAddress = pSalesRepAddress;
     VisitingDoctor  = pSalesRep.VisitingDoctor;
     DoctorAddress   = pSalesRep.DoctorAddress;
 }
Example #9
0
        public List <SalesRep> GetInvoicesBySalesRep()
        {
            using (var connection = new SqlConnection(_connectionString))
            {
                var cmd = connection.CreateCommand();
                cmd.CommandText = @"select e.firstname + ' ' + e.lastname as Name, i.InvoiceId from Employee e
                                    join customer c on c.SupportRepId = e.EmployeeId
                                    join invoice i on i.CustomerId = c.CustomerId
                                    where e.title = 'Sales Support Agent'";

                connection.Open();
                var reader = cmd.ExecuteReader();

                var employees = new List <SalesRep>();

                while (reader.Read())
                {
                    var employee = new SalesRep
                    {
                        Name      = reader["Name"].ToString(),
                        InvoiceId = int.Parse(reader["InvoiceId"].ToString())
                    };

                    employees.Add(employee);
                }
                return(employees);
            }
        }
Example #10
0
        private void GrabCustomer_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            if (e.SelectedObjects.Count > 0)
            {
                if (this.GetAvailableSnatchLimit(SecuritySystem.CurrentUserName) >= e.SelectedObjects.Count)
                {
                    using (IObjectSpace os = Application.CreateObjectSpace())
                    {
                        SalesRep SR = os.FindObject <SalesRep>(new BinaryOperator("SalesRepCode", SecuritySystem.CurrentUserName.ToUpper()));
                        if (SR == null)
                        {
                            SR = os.CreateObject <SalesRep>();
                            SR.SalesRepCode = SecuritySystem.CurrentUserName;
                            os.CommitChanges();
                        }

                        foreach (CustomerRelease selectedCustomer in e.SelectedObjects)
                        {
                            CustomerRelease custr = os.GetObject <CustomerRelease>(selectedCustomer);
                            custr.AquiredBy   = SecuritySystem.CurrentUserName.ToUpper();
                            custr.AquiredDate = DateTime.Now;
                            Customer cust = os.FindObject <Customer>(new BinaryOperator("Oid", custr.Customer));

                            cust.SalesRep           = SR;
                            cust.SalesRepAssignedDt = DateTime.Now;
                        }
                        os.CommitChanges();
                        ((ListView)View).CollectionSource.Reload();
                    }
                }
            }
        }
Example #11
0
        private void InsertSalesInfo(object sender, EventArgs e)
        {
            rand            = r.Next(111111, 999999);
            salesIDBox.Text = "sales" + rand;

            SalesRep sr = new SalesRep();

            sr.SalesID      = this.salesIDBox.Text;
            sr.CustName     = this.custnameBox.Text;
            sr.CustAddress  = this.custadbox.Text;
            sr.CustContacts = this.custcontactBox.Text;
            sr.CustMail     = this.custmailBox.Text;
            sr.VecModel     = this.modelBox.Text;
            sr.VecNetCost   = this.costBox.Text;
            sr.Payment      = this.combopaymentBox.Text;
            sr.Date         = this.dateTimePicker2.Text;
            sr.SalesInvoice = i;

            Console.WriteLine(i);

            SalesRepositoryDB srdb = new SalesRepositoryDB();

            if (srdb.Insert(sr))
            {
                MessageBox.Show("Insert Completed!", "Succeed");
            }

            else
            {
                MessageBox.Show("Insert Not Complete", "Error");
            }
        }
Example #12
0
        public static Mock <IUnitOfWork> SetupUnitOfWork()
        {
            Mock <IUnitOfWork> unitOfWork = new Mock <IUnitOfWork>();

            SalesRep rep1 = new SalesRep
            {
                Id        = 1,
                FirstName = "Andrew",
                LastName  = "Stoddard",
                BirthDate = new DateTime(2000, 8, 18),
                HireDate  = DateTime.Today,
                ManagerId = 0
            };
            SalesRep rep2 = new SalesRep
            {
                Id        = 2,
                FirstName = "Ze",
                LastName  = "Ze",
                BirthDate = new DateTime(2000, 8, 18),
                HireDate  = DateTime.Today,
                ManagerId = 0
            };
            SalesRep rep3 = new SalesRep
            {
                Id        = 3,
                FirstName = "Tony",
                LastName  = "Lazuto",
                BirthDate = new DateTime(2000, 8, 18),
                HireDate  = DateTime.Today,
                ManagerId = 0
            };
            List <SalesRep> reps = new List <SalesRep>
            {
                rep1,
                rep2,
                rep3
            };
            List <Sale> sales = new List <Sale>
            {
                new Sale {
                    Year = 2016, Month = 1, SalesRepId = 1, SalesRep = rep1, Amount = 20
                },
                new Sale {
                    Year = 2018, Month = 12, SalesRepId = 3, SalesRep = rep3, Amount = 100
                },
                new Sale {
                    Year = 2017, Month = 5, SalesRepId = 2, SalesRep = rep2, Amount = 50
                }
            };
            Mock <IRepository <Sale> >     saleRepo     = new Mock <IRepository <Sale> >();
            Mock <IRepository <SalesRep> > salesRepRepo = new Mock <IRepository <SalesRep> >();

            saleRepo.Setup(repo => repo.Get(null)).Returns(sales.AsQueryable());
            salesRepRepo.Setup(repo => repo.Get(null)).Returns(reps.AsQueryable());
            unitOfWork.Setup(w => w.Sales).Returns(saleRepo.Object);
            unitOfWork.Setup(w => w.SalesReps).Returns(salesRepRepo.Object);

            return(unitOfWork);
        }
Example #13
0
        public void SalesRepQueryUsingoAuth()
        {
            QueryService <SalesRep> entityQuery = new QueryService <SalesRep>(qboContextoAuth);
            SalesRep        existing            = Helper.FindOrAdd <SalesRep>(qboContextoAuth, new SalesRep());
            List <SalesRep> entities            = entityQuery.ExecuteIdsQuery("Select * from Customer where Id == " + existing.Id + "'").ToList();

            Assert.IsTrue(entities.Count() > 0);
        }
Example #14
0
        public ActionResult Index(int userLogin)
        {
            var item = db.salesrep.Where(x => x.UserID == userLogin).First();

            currentUser         = item;
            ViewBag.CurrentUser = currentUser.RepFirstName + ' ' + currentUser.RepLastName;
            return(View());
        }
Example #15
0
        public void SalesRepQueryUsingoAuth()
        {
            QueryService <SalesRep> entityQuery = new QueryService <SalesRep>(qboContextoAuth);
            SalesRep        existing            = Helper.FindOrAdd <SalesRep>(qboContextoAuth, new SalesRep());
            List <SalesRep> entities            = entityQuery.Where(c => c.Id == existing.Id).ToList();

            Assert.IsTrue(entities.Count() > 0);
        }
Example #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            SalesRep salesRep = db.SalesReps.Find(id);

            db.SalesReps.Remove(salesRep);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #17
0
        public void SalesRepVoidAsyncTestsUsingoAuth()
        {
            //Creating the SalesRep for Adding
            SalesRep entity = QBOHelper.CreateSalesRep(qboContextoAuth);
            //Adding the SalesRep
            SalesRep added = Helper.Add <SalesRep>(qboContextoAuth, entity);

            Helper.VoidAsync <SalesRep>(qboContextoAuth, added);
        }
Example #18
0
        public void SalesRepAddAsyncTestsUsingoAuth()
        {
            //Creating the SalesRep for Add
            SalesRep entity = QBOHelper.CreateSalesRep(qboContextoAuth);

            SalesRep added = Helper.AddAsync <SalesRep>(qboContextoAuth, entity);

            QBOHelper.VerifySalesRep(entity, added);
        }
Example #19
0
        public void SalesRepFindbyIdTestUsingoAuth()
        {
            //Creating the SalesRep for Adding
            SalesRep salesRep = QBOHelper.CreateSalesRep(qboContextoAuth);
            //Adding the SalesRep
            SalesRep added = Helper.Add <SalesRep>(qboContextoAuth, salesRep);
            SalesRep found = Helper.FindById <SalesRep>(qboContextoAuth, added);

            QBOHelper.VerifySalesRep(found, added);
        }
Example #20
0
 public ActionResult Edit([Bind(Include = "SalesRepId,FirstName,LastName,email,phone")] SalesRep salesRep)
 {
     if (ModelState.IsValid)
     {
         db.Entry(salesRep).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(salesRep));
 }
Example #21
0
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,Password")] SalesRep salesrep)
 {
     if (ModelState.IsValid)
     {
         db.Entry(salesrep).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(salesrep));
 }
Example #22
0
        public void SalesRepAddTestUsingoAuth()
        {
            //Creating the SalesRep for Add
            SalesRep salesRep = QBOHelper.CreateSalesRep(qboContextoAuth);
            //Adding the SalesRep
            SalesRep added = Helper.Add <SalesRep>(qboContextoAuth, salesRep);

            //Verify the added SalesRep
            QBOHelper.VerifySalesRep(salesRep, added);
        }
Example #23
0
        public ActionResult Create([Bind(Include = "SalesRepId,FirstName,LastName,email,phone")] SalesRep salesRep)
        {
            if (ModelState.IsValid)
            {
                db.SalesReps.Add(salesRep);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(salesRep));
        }
Example #24
0
        static void Main(string[] args)
        {
            SalesRep DrA_Obj = new SalesRep("Doctor A", "Delhi");
            SalesRep DrB_Obj = new SalesRep("Doctor B", "Mumbai");
            SalesRep DrC_Obj = new SalesRep("Doctor C", "Bangalore");

            Dictionary <int, string> SalesRepDetails = new Dictionary <int, string>();

            SalesRepDetails.Add(10001, "Delhi");
            SalesRepDetails.Add(10002, "Mumbai");
            SalesRepDetails.Add(10003, "Delhi");
            SalesRepDetails.Add(10004, "Mumbai");
            SalesRepDetails.Add(10005, "Delhi");
            SalesRepDetails.Add(10006, "Delhi");
            SalesRepDetails.Add(10007, "Bangalore");
            SalesRepDetails.Add(10008, "Delhi");
            SalesRepDetails.Add(10009, "Bangalore");
            SalesRepDetails.Add(10010, "Mumbai");



            List <SalesRep> LstSalesRepObjects = new List <SalesRep>();

            SalesRep SalesRepObj;

            foreach (KeyValuePair <int, string> SingleSalesRepDetails in SalesRepDetails)
            {
                if (SingleSalesRepDetails.Value == "Delhi")
                {
                    SalesRepObj = new SalesRep(DrA_Obj, SingleSalesRepDetails.Key, SingleSalesRepDetails.Value);
                }
                else if (SingleSalesRepDetails.Value == "Mumbai")
                {
                    SalesRepObj = new SalesRep(DrB_Obj, SingleSalesRepDetails.Key, SingleSalesRepDetails.Value);
                }
                else
                //(SingleSalesRepDetails.Value == "Bangalore")
                {
                    SalesRepObj = new SalesRep(DrC_Obj, SingleSalesRepDetails.Key, SingleSalesRepDetails.Value);
                }
                LstSalesRepObjects.Add(SalesRepObj);
            }

            foreach (SalesRep SingleSalesRepObject in LstSalesRepObjects)
            {
                StringBuilder SbMessage = new StringBuilder();
                SbMessage.Append("Sales Rep with ID " + SingleSalesRepObject.SalesRepID + "   ");
                SbMessage.Append("Living in the address " + SingleSalesRepObject.SalesRepAddress + "   ");
                SbMessage.Append("Visiting the doctor " + SingleSalesRepObject.VisitingDoctor + "   ");
                SbMessage.Append("Who is living in " + SingleSalesRepObject.DoctorAddress + "   ");
                Console.WriteLine(SbMessage.ToString());
            }
            Console.ReadLine();
        }
        public void CheckEmployeeLocation_ShouldBeInParkingLot(int monthlyGoal, int teamGoal, int salesToday)
        {
            //Arrange
            var salesRep = new SalesRep(monthlyGoal, teamGoal, salesToday);

            //Act
            var expectedLocation = LocationEnum.ParkingLot;

            //Assert
            Assert.AreEqual(expectedLocation, salesRep.CurrentLocation);
        }
        /// <summary>
        ///     Checks the sales rep exists.
        /// </summary>
        /// <param name="unitOfWork">The unit of work.</param>
        /// <param name="rep">The rep.</param>
        /// <returns>System.String.</returns>
        public static string CheckSalesRepExists(IUnitOfWork unitOfWork, SalesRep rep)
        {
            if (unitOfWork.SalesReps.Get().ToList().Exists(r =>
                                                           r.FirstName == rep.FirstName && r.LastName == rep.LastName &&
                                                           r.BirthDate.Date.CompareTo(rep.BirthDate.Date) == 0))
            {
                return($"{rep.FirstName} {rep.LastName} already exists.");
            }

            return("");
        }
Example #27
0
        public async Task <IHttpActionResult> GetSalesRep(int id)
        {
            SalesRep salesRep = await db.SalesReps.FindAsync(id);

            if (salesRep == null)
            {
                return(NotFound());
            }

            return(Ok(salesRep));
        }
Example #28
0
        public IHttpActionResult PostSalesRep(SalesRep salesRep)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SalesReps.Add(salesRep);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = salesRep.SalesRepId }, salesRep));
        }
Example #29
0
        public async Task <IHttpActionResult> PostSalesRep(SalesRep salesRep)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SalesReps.Add(salesRep);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = salesRep.id }, salesRep));
        }
Example #30
0
        private byte[] GenerateSalesRepCommissionData(int month, int year, string format)
        {
            if (month == 0 || year == 0)
            {
                return(null);
            }
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Server.MapPath("~/Report/rpSalesRepCommission.rdlc");

            if (Session["LoggedUser"] == null || !(Session["LoggedUser"] is SalesRep))
            {
                return(null);
            }

            SalesRep salesRep = (SalesRep)Session["LoggedUser"];

            var salesRepCommission = new ReportDAL().GetSalesRepCommission(salesRep.ID, month, year);

            string period = string.Format("{0}/{1}", month, year);

            ReportParameter pSalesRepName       = new ReportParameter("SalesRepName", string.Format("{0} {1}", salesRep.FirstName, salesRep.LastName));
            ReportParameter pSalesRepCommission = new ReportParameter("SalesRepCommission", String.Format("{0:0.00}", salesRepCommission));
            ReportParameter pPeriod             = new ReportParameter("Period", period);

            localReport.SetParameters(pSalesRepName);
            localReport.SetParameters(pSalesRepCommission);
            localReport.SetParameters(pPeriod);

            string mimeType;
            string encoding;
            string fileNameExtension;
            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
            string deviceInfo = "<DeviceInfo>" +
                                "  <OutputFormat>jpeg</OutputFormat>" +
                                "  <PageWidth>8.5in</PageWidth>" +
                                "  <PageHeight>11in</PageHeight>" +
                                "  <MarginTop>0.5in</MarginTop>" +
                                "  <MarginLeft>1in</MarginLeft>" +
                                "  <MarginRight>1in</MarginRight>" +
                                "  <MarginBottom>0.5in</MarginBottom>" +
                                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;

            //Render the report
            renderedBytes = localReport.Render(format, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            return(renderedBytes);
        }