Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Code,Isocode2,Isocode3,DialCode,Nationality,CreatedBy]")] Country country)
        {
            if (ModelState.IsValid)
            {
                country.CreatedBy = Convert.ToInt32(HttpContext.Session.GetInt32("UserId"));

                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Description,Status")] Issue issue)
        {
            if (ModelState.IsValid)
            {
                _context.Add(issue);
                await _context.SaveChangesAsync();

                await _hubContext.Clients.All.SendAsync("OnIssueCreate", issue);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(issue));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,DateTime")] Tournament tournament)
        {
            initDataView();
            tournament.UserId = GetIdUser();
            if (ModelState.IsValid)
            {
                _context.Add(tournament);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tournament));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create(int ID, string Name, int Price, string Category)
        {
            db.Add(new Service
            {
                ID       = ID,
                Name     = Name,
                Price    = Price,
                Category = Category
            });
            await db.SaveChangesAsync();

            return(RedirectToAction(nameof(Allservices)));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(SubscriptionPlan entity, [Required] int durationInDays)
        {
            if (ModelState.IsValid)
            {
                entity.Duration = TimeSpan.FromDays(durationInDays);
                _context.Add(entity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Edit).ToString(), new { id = entity.Id }));
            }

            return(View(entity));
        }
        public async Task <IActionResult> Create([Bind("Id,Uiid,RoleId")] UIRoleMap uIRoleMap)
        {
            if (ModelState.IsValid)
            {
                _context.Add(uIRoleMap);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleId"] = new SelectList(_context.RoleMaster, "Id", "Code", uIRoleMap.RoleId);
            ViewData["Uiid"]   = new SelectList(_context.UIMaster, "Id", "Name", uIRoleMap.Uiid);
            return(View(uIRoleMap));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("Id,UserId,GroupId")] UsersGroup usersGroup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(usersGroup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "Name", usersGroup.GroupId);
            ViewData["UserId"]  = new SelectList(_context.Users, "Id", "Email", usersGroup.UserId);
            return(View(usersGroup));
        }
Esempio n. 8
0
        public async Task <IActionResult> Create([Bind("Title,Description,CategoryId,Price,TypeId,Id,Created")] Clothes clothes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clothes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "Id", clothes.CategoryId);
            ViewData["TypeId"]     = new SelectList(_context.Type, "Id", "Id", clothes.TypeId);
            return(View(clothes));
        }
        public async Task <T> Add(T entity)
        {
            _context.Add(entity);

            if (await _context.SaveEntitiesAsync())
            {
                return(await _context.Set <T>()
                       .ToAsyncEnumerable()
                       .SingleOrDefault(e => e.Id == entity.Id));
            }

            throw new ArgumentNullException(nameof(T)); //NOTIFICATION
        }
Esempio n. 10
0
        public IActionResult NewPet([FromBody] Pet pet)
        {
            PetOwner petOwner = _context.petOwners.SingleOrDefault(p => p.id == pet.petOwnerid);

            if (petOwner == null)
            {
                return(BadRequest());
            }

            _context.Add(pet);
            _context.SaveChanges();
            return(CreatedAtAction(nameof(NewPet), new { id = pet.id }, pet));
        }
        public Contact AddContact(Contact contact)
        {
            Contact item = null;

            if (GetContactByName(contact.Name) == null)
            {
                _fileService.SaveImage(contact.ProfileImage, contact.Name);
                item = _context.Add(contact).Entity;
                _context.SaveChanges();
            }

            return(item);
        }
        public async Task <IActionResult> Create([Bind("Id,PeopleId,SubjectId,DateTime,Note")] Schedule schedule)
        {
            if (ModelState.IsValid)
            {
                _context.Add(schedule);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PeopleId"]  = new SelectList(_context.Peoples, "Id", nameof(People.Name), schedule.PeopleId);
            ViewData["SubjectId"] = new SelectList(_context.Subjects, "Id", nameof(Subject.Name), schedule.SubjectId);
            return(View(schedule));
        }
Esempio n. 13
0
        public async Task <IActionResult> Create([Bind("Id,UserName,UserPhoneNo,UserPassword,IsActive,Role,Latitude,Longitude,ModeratorId,PointsAccumulated")] User user)
        {
            var currentUser = getCurrentUser();

            if (ModelState.IsValid)
            {
                user.ModeratorId = currentUser.Id;
                _context.Add(user);
                await _context.SaveChangesAsync();
            }
            //return View(user);
            return(RedirectToAction("Index", "User"));
        }
Esempio n. 14
0
        public void Add(RestaurantFoodDTO modelDTO, IFormFile file)
        {
            var model = _mapper.Map <RestaurantFood>(modelDTO);

            Errors.ThrowIfNull(model);

            if (file != null)
            {
                model.PathToImage = AddFile(file);
            }

            _db.Add(model);
        }
        // GET: PassangerCarriegesInfoes/Details/5
        public async Task <IActionResult> Details(int?idcar)
        {
            if (idcar == null)
            {
                return(NotFound());
            }

            PassangerCarriere passangerCarriere = await _context.PassangerCarrieres.Where(x => x.id == idcar).FirstOrDefaultAsync();

            var passanger_carrieges_info = _context.PassangerCarriegesInfos.Where(m => m.Type == passangerCarriere.Calss).FirstOrDefault();

            if (passanger_carrieges_info == null)
            {
                PassangerCarriegesInfo passangerCarriegesInfo = new PassangerCarriegesInfo
                {
                    Type = passangerCarriere.Calss,
                    Info = ""
                };
                _context.Add(passangerCarriegesInfo);
                Trace.WriteLine("POST: " + passangerCarriegesInfo);
                await _context.SaveChangesAsync();
            }
            PassangerCarriegesInfo passangerCarriegesInfo_result;

            try
            {
                passangerCarriegesInfo_result = _context.PassangerCarriegesInfos.Where(m => m.Type == passangerCarriere.Calss).FirstOrDefault();
                if (passangerCarriegesInfo_result == null)
                {
                    return(View(Details(idcar)));
                }
            }
            catch (Exception exp)
            {
                return(NotFound());
            }
            Trace.WriteLine("RESPONSE: " + passangerCarriegesInfo_result);
            return(View(passangerCarriegesInfo_result));
        }
        public async Task <IActionResult> Create([Bind("DoctorId,FIO,PositionId")] Doctor doctor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(doctor);
                await _context.SaveChangesAsync();

                return(PartialView("Success"));
                //return RedirectToAction(nameof(Index));
            }
            ViewData["PositionId"] = new SelectList(_context.Positions, "PositionId", "PositionName", doctor.PositionId);
            return(PartialView(doctor));
        }
Esempio n. 17
0
        public async Task <IActionResult> Create([Bind("Id,Name,CreatedAt")] Chat chat)
        {
            chat.CreatedAt = DateTime.Now;
            string userId = _userManager.GetUserId(User);

            if (ModelState.IsValid)
            {
                _context.Add(chat);
                _context.SaveChanges();

                ChatUser chatUser = new ChatUser()
                {
                    CreatedAt = DateTime.Now,
                    ChatId    = chat.Id,
                    UserId    = userId
                };
                _context.Add(chatUser);
                _context.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(chat));
        }
        public async Task <IActionResult> Create([Bind("MainPlanId,SelectionСommitteeId,UserId,DateTime")] MainPlan mainPlan)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mainPlan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SelectionСommitteeId"] = new SelectList(_context.SelectionСommitties, "SelectionСommitteeId", "Name", mainPlan.SelectionСommitteeId);
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", mainPlan.UserId);
            return(View(mainPlan));
        }
Esempio n. 19
0
        public async Task <IActionResult> Create([Bind("ConnectionTableID,WorkerID,ProjectID")] ConnectionTable connectionTable)
        {
            if (ModelState.IsValid)
            {
                _context.Add(connectionTable);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectID"] = new SelectList(_context.Projects, "ProjectID", "ProjectID", connectionTable.ProjectID);
            ViewData["WorkerID"]  = new SelectList(_context.Workers, "WorkerID", "WorkerID", connectionTable.WorkerID);
            return(View(connectionTable));
        }
Esempio n. 20
0
        public async Task <IActionResult> Create([Bind("ProductsId,ProductTypeId,FactoryId,ProductName,UnitOfProduct")] Products products)
        {
            if (ModelState.IsValid)
            {
                _context.Add(products);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FactoryId"]     = new SelectList(_context.Factories, "FactoriesId", "FactoriesId", products.FactoryId);
            ViewData["ProductTypeId"] = new SelectList(_context.ProductTypes, "ProductTypesId", "ProductTypesId", products.ProductTypeId);
            return(View(products));
        }
Esempio n. 21
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] Location location)
        {
            initDataView();
            location.UserId = GetIdUser();
            if (ModelState.IsValid)
            {
                _context.Add(location);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(location));
        }
Esempio n. 22
0
        public void Send(Package package)
        {
            _context.Add(package);
            _context.SaveChanges();

            var encrepted = package.CreateEncreted();

            Clients.Group(Subject.Hacker.ToString()).onRecievePackage(package);

            Clients.Group(package.To.ToString()).onRecievePackage(package);

            City.GetInstance().GetObject(package.To).ProcessPackage(package);
        }
        public async Task <IActionResult> Create([Bind("Id,Email,Login,Password,FirstName,Name,LastName,Position,CityNumber,LocalNumber,MobileNumber,CabinetNumber,SequenceNumber,RoleId,DepartmentId")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(List)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Departments.OrderBy(d => d.SequenceNumber), "Id", "DepartmentName", user.DepartmentId);
            ViewData["RoleId"]       = new SelectList(_context.Roles, "Id", "RoleDescription", user.RoleId);
            return(View(user));
        }
        public void Post([FromBody] Movie value)
        {
            // Create movie in db logic
            Movie movie = new Movie()
            {
                Title    = value.Title,
                Genre    = value.Genre,
                Director = value.Director
            };

            _context.Add(movie);
            _context.SaveChanges();
        }
        public async Task <IActionResult> Create([Bind("ImageURL,Base64,Active,PostId,Id,CreatedComputerName,CreatedDate,CreatedBy,CreatedIp")] PostImage postImage)
        {
            if (ModelState.IsValid)
            {
                postImage.Id = Guid.NewGuid();
                _context.Add(postImage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostId"] = new SelectList(_context.Posts, "Id", "Content", postImage.PostId);
            return(View(postImage));
        }
Esempio n. 26
0
        public async Task <Process> CreateProcess(string company)
        {
            Process process = new Process
            {
                StartDate = DateTime.Now,
                Title     = company
            };

            _context.Add(process);
            await _context.SaveChangesAsync();

            return(process);
        }
Esempio n. 27
0
        public async Task <IActionResult> Deposit(ViewModels.Deposit depositViewModel)
        {
            try
            {
                var accountName = HttpContext.Session.GetString(SessionKeyAccountName);
                var accountId   = Convert.ToInt32(HttpContext.Session.GetString(SessionKeyAccountId));

                if (ModelState.IsValid)
                {
                    Transaction transaction = new Transaction();
                    transaction.AccountID       = accountId;
                    transaction.Amount          = depositViewModel.Amount;
                    transaction.TransactionType = Transaction.TransactionTypeEnum.Deposit;

                    _context.Add(transaction);
                    var commitResult = await _context.SaveChangesAsync();

                    if (commitResult > 0)
                    {
                        var account = await _context.Accounts
                                      .AsNoTracking()
                                      .SingleOrDefaultAsync(x => x.AccountID == transaction.AccountID);

                        account.Balance += transaction.Amount;
                        _context.Update(account);
                        await _context.SaveChangesAsync();
                    }
                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(null);
        }
        public async Task <IActionResult> Create(EntitySaleablePrice entitySaleablePrice)
        {
            if (ModelState.IsValid)
            {
                _context.Add(entitySaleablePrice);
                await _context.SaveChangesAsync();

                return(await RedirectToBaseById(entitySaleablePrice.EntityId));
            }
            ViewData["CurrencyId"] = new SelectList(_context.Currencies, "Id", "Key", entitySaleablePrice.CurrencyId);
            ViewData["EntityId"]   = new SelectList(_context.EntitiesSaleable, "Id", "Id", entitySaleablePrice.EntityId);
            return(View(entitySaleablePrice));
        }
Esempio n. 29
0
 //We build/define our templates here
 public static bool TemplateBuilder(this ApplicationContext db, GeneralCertificationTrainingTemplate trainingTemplate)
 {
     try
     {
         db.Add(trainingTemplate);
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 30
0
        public async Task <IActionResult> Create([Bind("SpecialtyId,Name,EducationType,Branch,GroupId,SpecializationId")] Specialty specialty)
        {
            if (ModelState.IsValid)
            {
                _context.Add(specialty);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"]          = new SelectList(_context.Groups, "GroupId", "GroupName", specialty.GroupId);
            ViewData["SpecializationId"] = new SelectList(_context.Specializations, "SpecializationId", "SpecializationName", specialty.SpecializationId);
            return(View(specialty));
        }