Exemplo n.º 1
0
        public async Task <IActionResult> PutLabour(int id, Labour labour)
        {
            if (id != labour.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutAdmin(int id, Admin admin)
        {
            if (id != admin.LoginId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutUsers(int id, Users users)
        {
            if (id != users.UserId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("LoginId,AdminName,Apassword,RoleA")] Admin admin)
        {
            if (ModelState.IsValid)
            {
                _context.Add(admin);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(admin));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Pswd,Cnfrmpswd,Profession,CityAddress,StateL,DailyWages,TimeDate,Available,Lcontact,RoleL,Ppic")] Labour labour)
        {
            if (ModelState.IsValid)
            {
                _context.Add(labour);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(labour));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("UserId,FirstName,LastName,CityAddress,StateC,Lcontact,PasswordC,ConfirmPassword,RoleU")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Pswd,Cnfrmpswd,Profession,CityAddress,StateL,DailyWages,TimeDate,Available,Lcontact,Ppic,PPicFile,RoleL")] Labour labour)
        {
            if (ModelState.IsValid)
            {
                string rootPath = _hostEnviroment.WebRootPath;
                string fileName = Path.GetFileName(labour.PPicFile.FileName);

                string pPath = Path.Combine(rootPath + "/Images/", fileName);
                labour.Ppic = fileName;
                var filStream = new FileStream(pPath, FileMode.Create);
                await labour.PPicFile.CopyToAsync(filStream);

                filStream.Close();
                _context.Add(labour);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(labour));
        }