Exemplo n.º 1
0
        public ActionResult EditNote(Note note)
        {
            if (ModelState.IsValid)
            {
                _context.Entry(note).State = EntityState.Modified;
                _context.SaveChanges();
                return(RedirectToAction("Details", "Employees", new { id = note.EmployeeId }));
            }

            return(View(note));
        }
Exemplo n.º 2
0
        public bool Edit(Company company, string logo)
        {
            try
            {
                if (logo.Length > 10)
                {
                    var extension = logo.Substring(logo.IndexOf(':') + 1);
                    var extLength = extension.IndexOf(';');
                    var allLength = extension.Length - extLength;
                    extension = extension.Remove(extLength, allLength);

                    var file = logo.Substring(logo.IndexOf(',') + 1);

                    var bytes = Convert.FromBase64String(file);
                    company.LogoMimeType = extension;
                    company.LogoData     = bytes;
                }

                db.Entry(company).State = EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw new Exception("Error: ", e);
            }
        }
Exemplo n.º 3
0
        public bool MoveToArchive(Guid id)
        {
            try
            {
                Employee employee = db.Employees.Find(id);
                employee.IsInArchive       = true;
                employee.MoveToArchiveTime = DateTime.Now;
                db.Entry(employee).State   = EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw new Exception("Error: ", e);
            }
        }
Exemplo n.º 4
0
        public ActionResult ConnectAgreement(Guid?earningId, Guid?agreementId)
        {
            if (ModelState.IsValid)
            {
                if (earningId != null && agreementId != null)
                {
                    var earning   = _db.Earnings.Find(earningId);
                    var agreement = _db.Agreements.Find(agreementId);

                    earning.AgreementId = agreementId;
                    agreement.EarningId = earningId;

                    _db.Entry(earning).State   = EntityState.Modified;
                    _db.Entry(agreement).State = EntityState.Modified;
                    _db.SaveChanges();

                    return(RedirectToAction("Details", "Employees", new { id = earning.EmployeeId }));
                }
            }

            return(View());
        }
Exemplo n.º 5
0
        public bool EditEvent(Event esmevent)
        {
            try
            {
                db.Entry(esmevent).State = EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw new Exception("Error: ", e);
            }
        }