示例#1
0
      //debug edit
      public ActionResult Edit(Client client, int id)
      {
          var UserId       = User.Identity.GetUserId();
          var company      = db.CompanyEmployees.SingleOrDefault(x => x.EmployeeId == UserId);
          var editedClient = db.Clients.Find(id);

          if (client.ClientEmail != editedClient.ClientEmail && db.Clients.Any(x => x.ClientEmail == client.ClientEmail))
          {
              return(RedirectToAction("EmailError"));
          }

          else if (client.BillByProject == false && client.BillByClient == false)
          {
              ModelState.AddModelError("bools", "You must select either to bill by client or project");
              return(View());
          }
          else if (client.BillByClient == true && client.BillByProject == true)
          {
              return(View());
          }
          else if (client.BillByProject == true && client.BillRate != null)
          {
              return(View());
          }
          else if (client.BillByClient == true && client.BillRate == null)
          {
              return(View());
          }
          //If email is different but everthing else is the same add new row in client
          else
          {
              editedClient.ClientName        = client.ClientName;
              editedClient.ClientPhoneNumber = client.ClientPhoneNumber;

              editedClient.ClientEmail   = client.ClientEmail;
              editedClient.ClientAddress = client.ClientAddress;
              if (client.BillByClient == true)
              {
                  client.BillByProject = false;
              }
              else if (client.BillByProject == true)
              {
                  client.BillByClient = false;
                  client.BillRate     = null;
              }
              editedClient.BillByClient    = client.BillByClient;
              editedClient.BillByProject   = client.BillByProject;
              editedClient.BillRate        = client.BillRate;
              db.Entry(editedClient).State = EntityState.Modified;
              db.SaveChanges();
              return(RedirectToAction("Index"));
          }
      }
        public ActionResult Edit(Project project)
        {
            var editedProject = db.Projects.Find(project.ProjectId);

            editedProject.ProjectName = project.ProjectName;
            editedProject.IsCompleted = project.IsCompleted;
            if (editedProject.IsCompleted == true)
            {
                editedProject.DateCompleted = DateTime.Now;
            }
            db.Entry(editedProject).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
        public ActionResult PaymentRecieved(int id)
        {
            var clientBill = db.ClientBills.Find(id);

            clientBill.DatePaymentRecieved = DateTime.Today;
            db.Entry(clientBill).State     = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(WorkSchedule workSchedule)
 {//project cpmpany client id's
     if (ModelState.IsValid)
     {
         db.Entry(workSchedule).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId = new SelectList(db.CompanyEmployees.Include("Employee").Where(x => x.CompanyId == workSchedule.CompanyId), "EmployeeId", "Employee.FullName");
     return(View(workSchedule));
 }
        public ActionResult Edit(Company company)
        {
            var Company = db.Companies.Find(company.CompanyId);

            Company.Address            = company.Address;
            Company.ClientBillInterval = company.ClientBillInterval;
            Company.CompanyName        = company.CompanyName;
            Company.CompanyPhoneNumber = company.CompanyPhoneNumber;
            Company.Email = company.Email;
            Company.EmployeePayInterval = company.EmployeePayInterval;
            Company.Password            = company.Password;
            db.Entry(Company).State     = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Details"));
        }
示例#6
0
      public ActionResult PunchOut()
      {
          var      FindUser = User.Identity.GetUserId();
          DateTime date     = DateTime.Now;
          TimeSpan span     = new TimeSpan(10, 0, 0);
          DateTime time     = date - span;
          var      Entry    = db.TimeSheetEntries.FirstOrDefault(x => x.EmployeeId == FindUser && x.StartTime >= time && x.EndTime == null);
          var      start    = Entry.StartTime;

          ViewBag.Error = DateTime.Now - start > span;
          if (DateTime.Now - start < span)
          {
              var end = Entry.EndTime = DateTime.Now;
              db.Entry(Entry).CurrentValues.SetValues(end);
              db.SaveChanges();
              return(View());
          }

          else
          {
              ModelState.AddModelError("punchout", "The system does'nt handle such long work interval's please contact your administartor");
              return(View());
          }
      }