Exemplo n.º 1
0
        public bool Create(Company company, UserCompanyRef userCompanyRef, string userId, 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;
                }

                userCompanyRef.UserId    = userId;
                userCompanyRef.CompanyId = company.CompanyId;

                db.Companies.Add(company);
                db.UserCompanyRefs.Add(userCompanyRef);
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw new Exception("Error: ", e);
            }
        }
Exemplo n.º 2
0
        public bool Create(Employee employee, string currentCompanyId, string picture)
        {
            try
            {
                employee.CompanyId = Guid.Parse(currentCompanyId);
                if (picture.Length > 10)
                {
                    var extension = picture.Substring(picture.IndexOf(':') + 1);
                    var extLength = extension.IndexOf(';');
                    var allLength = extension.Length - extLength;
                    extension = extension.Remove(extLength, allLength);

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

                    var bytes = Convert.FromBase64String(file);
                    employee.PictureMimeType = extension;
                    employee.PictureData     = bytes;
                }

                db.Employees.Add(employee);
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw new Exception("Error: ", e);
            }
        }
Exemplo n.º 3
0
        public ActionResult AddNote(Note note)
        {
            if (ModelState.IsValid)
            {
                _context.Notes.Add(note);
                _context.SaveChanges();
                return(RedirectToAction("Details", "Employees", new { id = note.EmployeeId }));
            }

            return(View(note));
        }
Exemplo n.º 4
0
        public ActionResult AddEarning(Earning earning)
        {
            var employeeId = earning.EmployeeId;

            if (ModelState.IsValid)
            {
                _db.Earnings.Add(earning);
                _db.SaveChanges();
                return(RedirectToAction("Details", "Employees", new { id = employeeId }));
            }
            return(View(earning));
        }
Exemplo n.º 5
0
        public ActionResult AddPartial(PartialEarning partial)
        {
            var earningId = partial.EarningId;

            if (ModelState.IsValid)
            {
                _context.PartialEarnings.Add(partial);
                _context.SaveChanges();
                return(RedirectToAction("Details", "Earnings", new { id = earningId }));
            }

            return(View(partial));
        }
Exemplo n.º 6
0
        public bool CreateCompanyEvent(Event esmevent)
        {
            try
            {
                db.Events.Add(esmevent);
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw new Exception("Error: ", e);
            }
        }
Exemplo n.º 7
0
        public bool SaveCertyficationToDb(string uploadPath, Certyfication certyfication)
        {
            try
            {
                certyfication.FilePath = uploadPath;
                db.Certyfications.Add(certyfication);
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw new Exception("Error: ", e);
            }
        }
Exemplo n.º 8
0
        public bool SaveRecruitmentToDb(string uploadPath, RecruitmentDocument recruitment)
        {
            try
            {
                recruitment.FilePath = uploadPath;
                db.RecruitmentDocuments.Add(recruitment);
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw new Exception("Error: ", e);
            }
        }
Exemplo n.º 9
0
        public bool SaveAgreementToDb(string uploadPath, Agreement agreement)
        {
            try
            {
                agreement.FilePath = uploadPath;
                db.Agreements.Add(agreement);
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

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