예제 #1
0
        public IActionResult Post([FromBody] BucketlistDto dto)
        {
            BucketlistModel bucketlistModel = new BucketlistModel
            {
                Created_By    = dto.Created_By,
                Date_Created  = DateTime.Today,
                Date_Modified = DateTime.Today,
                Items         = dto.Items.Count <= 0 ? "Item not set" : "item set",
                Name          = dto.Name
            };

            _Service.Add(bucketlistModel);
            if (dto.Items.Count > 0)
            {
                foreach (var item in dto.Items)
                {
                    BucketlistItem bucketlistItem = new BucketlistItem
                    {
                        Date_Created  = DateTime.Today.Date,
                        Date_Modified = DateTime.Today.Date,
                        Done          = item.Done,
                        Name          = item.Name,
                        BucketlistId  = bucketlistModel.Id.ToString()
                    };
                    _Service.Add(bucketlistItem);
                }
            }
            _Service.Save();

            return(Ok("Added Successfully", isSuccessful: true));
        }
예제 #2
0
        public static void AddingPersons()
        {
            var docDantist = doctorFactory.GetPerson();

            InitDoctor(docDantist, personId, "Ivan", "Bo", "Junior");
            doctors.Add(docDantist);

            var docSurgeon = doctorFactory.GetPerson();

            InitDoctor(docSurgeon, personId, "Alex", "Tor", "Middle");
            doctors.Add(docSurgeon);

            var n = 10;

            for (var i = 0; i < 10; i++)
            {
                var patient = patientFactory.GetPerson();
                if (i > n / 2)
                {
                    InitPatient(patient, personId, "Name" + i, "LastName" + i, docDantist.Id, i + 10);
                }
                else
                {
                    InitPatient(patient, personId, "Name" + i, "LastName" + i, docSurgeon.Id, i + 10);
                }

                patients.Add(patient);
            }
        }
예제 #3
0
        public void Add(LicenseMatch data)
        {
            // Validate data

            // Save data
            _service.Add(data);
        }
예제 #4
0
        public void Add_When_ticketModel_is_valid_Then_return_created_model_id()
        {
            var validDto = new TicketDto
            {
                FlightNumber = "YM-222",
                Price        = 3000
            };

            var result = _service.Add(validDto);

            Assert.AreEqual(result, 1);
        }
        public void Add_When_pilotModel_is_valid_Then_return_created_model_id()
        {
            var validDto = new PilotDto {
                FirstName  = "Petro",
                LastName   = "Boroda",
                Birthdate  = new DateTime(1989, 10, 12),
                Experience = 4
            };

            var result = _service.Add(validDto);

            Assert.AreEqual(result, 1);
        }
        public void Add_When_stewardesseModel_is_valid_Then_return_created_model_id()
        {
            var validDto = new StewardesseDto
            {
                FirstName = "Anna",
                LastName  = "Karenina",
                Birthdate = new DateTime(1991, 9, 12)
            };

            var result = _service.Add(validDto);

            Assert.AreEqual(result, 1);
        }
예제 #7
0
        public void Add_When_airplaneTypeModel_is_valid_Then_return_created_model_id()
        {
            var validDto = new AirplaneTypeDto
            {
                AirplaneModel    = "YZ-222",
                CarryingCapacity = 14000,
                SeatsCount       = 987
            };

            var result = _service.Add(validDto);

            Assert.AreEqual(result, 1);
        }
예제 #8
0
        public ActionResult TestSample()
        {
            var sampleModel = new SampleModel
            {
                Name        = "Bob Jackson",
                CurrentDate = DateTime.Now
            };

            _service.Add(sampleModel);
            _unitOfWork.Commit();

            return(View());
        }
예제 #9
0
 public ActionResult Add(Car item)
 {
     if (ModelState.IsValid)
     {
         try {
             _carService.Add(item);
             _carService.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception ex) {
             ViewBag.Error = ex.Message;
         }
     }
     return(View(item));
 }
예제 #10
0
        public void CreateClauseTemplate(int sectionId, LicenseClauseTemplateModel model, LoggedInUserDetails user)
        {
            // Check whether user is not admin
            if (!user.IsSysAdmin)
            {
                throw new BaseException("Access denied.");
            }

            // Get clauses for section
            var clauses = _clauses.Where(p => p.LicenseSectionID == sectionId).ToList();

            // Setup available order position
            var lastOrderNumber = 0;

            if (clauses.Any())
            {
                lastOrderNumber = clauses.Max(p => p.OrderNumber);
            }

            // Setup license clause
            var licenseClause = new LicenseClause
            {
                LicenseSectionID = model.LicenseSectionId,
                CreatedAt        = GetDate,
                CreatedBy        = user.ID.Value,
                OrderNumber      = lastOrderNumber + 1
            };

            // Save license clause
            _clauses.Add(licenseClause);

            // Setup clause template
            var clauseTemplate = new LicenseClauseTemplate
            {
                CreatedAt       = GetDate,
                CreatedBy       = user.ID.Value,
                Description     = model.Description,
                LegalText       = model.LegalText,
                LicenseClauseID = licenseClause.ID,
                ClauseType      = (int)GetTypeForClause(model.LegalText),
                ShortText       = model.ShortText,
                Status          = (int)TemplateStatus.Draft,
                Version         = 1
            };

            // Save clause template
            _clauseTemplates.Add(clauseTemplate);
        }
예제 #11
0
        public async Task <IHttpActionResult> Post(Person person)
        {
            _personService.Add(person);
            await _personService.SaveChangesAsync();

            return(Ok());
        }
예제 #12
0
        public ActionResult Create(ProductViewModel _product)
        {
            ProductDTO product = new ProductDTO();

            if (ModelState.IsValid)
            {
                if (productService.GetAll().Where(x => x.Name == _product.Name).Count() > 0)
                {
                    return(RedirectToAction("Error", new { exeption = "The product already exist!" }));
                }
                else
                {
                    product.Name        = _product.Name;
                    product.Price       = _product.Price;
                    product.Description = _product.Description;
                    product.CategoryId  = _product.CategoryId;
                    product.BrandId     = _product.BrandId;
                    product.Image       = _product.Image != null?ImageConverter.GetBytes(_product.Image) : null;

                    productService.Add(product);
                    productService.Save();
                    return(RedirectToAction(nameof(List)));
                }
            }
            ViewData["BrandId"]    = new SelectList(brandService.GetAll(), "BrandId", "Name", _product.BrandId);
            ViewData["CategoryId"] = new SelectList(categoryService.GetAll(), "CategoryId", "Name", _product.CategoryId);
            return(View(_product));
        }
 private void bttaohd_Click(object sender, EventArgs e)
 {
     try
     {
         if (list == null)
         {
             XtraMessageBox.Show("Chưa thêm sản phẩm, không thể tạo hợp đồng!", "Thông báo");
         }
         else
         {
             contract.Add(con);
             foreach (var item in list)
             {
                 item.ContractID = contract.GetAll()[contract.GetAll().Count - 1].ContractID;
             }
             foreach (var item in list)
             {
                 contractDetail.Add(item);
             }
             XtraMessageBox.Show("Tạo hợp đồng thành công!", "Thông báo");
             done = true;
             this.Close();
         }
     }
     catch
     {
         contract.Delete(con.ContractID);
         XtraMessageBox.Show("Please try again!", "Thông báo");
     }
 }
예제 #14
0
        public ActionResult Create(TagView tag, int postId)
        {
            try
            {
                var post = postService.GetById(postId);
                if (post == null)
                {
                    return(View("Error"));
                }

                var existingTag = tagService.GetAll()
                                  .FirstOrDefault(t => t.Name == tag.Name);

                if (existingTag == null)
                {
                    existingTag = tagService.Add(tag);
                }

                existingTag.Posts.Add(post);
                tagService.Update(existingTag);

                return(RedirectToAction("Edit", "Post", new { id = postId }));
            }
            catch
            {
                return(View("Error"));
            }
        }
예제 #15
0
        public Task StoreAsync(is4Models.PersistedGrant token)
        {
            var existing = _persistedGrantService.GetSingle(x => x.Key == token.Key);

            try
            {
                if (existing == null)
                {
                    _logger.LogDebug("{persistedGrantKey} not found in database", token.Key);

                    var persistedGrant = _mapper.Map <is4Entity.PersistedGrant>(token);
                    _persistedGrantService.Add(persistedGrant);
                }
                else
                {
                    _logger.LogDebug("{persistedGrantKey} found in database", token.Key);

                    _persistedGrantService.Update(existing);
                }
            }
            catch (DbUpdateConcurrencyException ex)
            {
                _logger.LogWarning("exception updating {persistedGrantKey} persisted grant in database: {error}", token.Key, ex.Message);
            }


            return(Task.FromResult(0));
        }
예제 #16
0
        public Task AddClaimsAsync(User user, IEnumerable <Claim> claims, CancellationToken cancellationToken)
        {
            if (cancellationToken != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
            }

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            if (claims == null)
            {
                throw new ArgumentNullException(nameof(claims));
            }

            var userClaims = new List <UserClaim>();

            foreach (var claim in claims.ToList())
            {
                userClaims.Add(new UserClaim()
                {
                    ClaimType  = claim.Type,
                    ClaimValue = claim.Value,
                    UserId     = user.Id
                });
            }
            if (userClaims.Count() > 0)
            {
                _userClaimService.Add(userClaims.ToList());
            }

            return(Task.CompletedTask);
        }
        private void SaveProviderLicense(int licenseTemplateId, int schemaId, int applicationId, List <SectionsWithClauses> model, LoggedInUserDetails user)
        {
            // Get endpoint
            var endpoint = _endpoints.Where(i => i.ApplicationId == applicationId)
                           .FirstOrDefault(i => i.DataSchemaID == schemaId);

            // Setup organization license
            var license = new OrganizationLicense
            {
                LicenseTemplateID  = licenseTemplateId,
                ApplicationID      = applicationId,
                DataSchemaID       = schemaId,
                ProviderEndpointID = endpoint.ID,
                CreatedBy          = user.ID.Value,
                CreatedAt          = GetDate,
                Status             = (int)TemplateStatus.Draft
            };

            // Save organization license
            _service.Add(license);

            // Save license clauses
            foreach (var section in model)
            {
                // Skip not selected section
                if (!_licenseClauses.IsClauseSelected(section))
                {
                    continue;
                }
                var selectedClause = section.Clauses.First(p => p.ClauseTemplateId == section.SelectedClause);
                var clause         = SetupLicenseClause(selectedClause, license, user);
                _licenseClauseService.Add(clause);
            }
        }
예제 #18
0
 private void Add()
 {
     try
     {
         Survey survey = new Survey(txtName.Text, Convert.ToInt32(txtQuantity.Text), username);
         var    exist  = _service.Get(txtName.Text.ToUpper(), username);
         if (!exist)
         {
             _service.Add(survey);
             frmQuestions frmQuestions = new frmQuestions();
             frmQuestions.SurveyId = _service.GetId(survey);
             frmQuestions.Quantity = Convert.ToInt32(txtQuantity.Text);
             frmQuestions.userName = username;
             this.Hide();
             frmQuestions.Show();
         }
         else
         {
             MessageBox.Show("Ya tiene una encuesta con ese nombre, escriba uno diferente");
         }
     }catch (Exception e)
     {
         MessageBox.Show("Ha ocurrido un error, verifique los valores introducidos sean correctos");
     }
 }
예제 #19
0
        public virtual IHttpActionResult Post(T entity)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Model Invalid");
                }


                var response = service.Add(entity);

                if (!response.IsSuccessful)
                {
                    throw new Exception(string.Join(",", response.ErrorMessages));
                }

                return(FinalizeResponse(response, string.Empty));
            }
            catch (Exception ex)
            {
                logger.LogError(ex);
                return(InternalServerError(new Exception(ex.Message)));
            }
        }
예제 #20
0
        public ActionResult Create(TattooViewModel _tattoo)
        {
            TattooDTO tattoo = new TattooDTO();

            if (ModelState.IsValid)
            {
                if (tattooService.GetAll().Where(x => x.Name == _tattoo.Name).Count() > 0)
                {
                    return(RedirectToAction("Error", new { exeption = "The tattoo already exist!" }));
                }
                else
                {
                    tattoo.Name       = _tattoo.Name;
                    tattoo.Price      = _tattoo.Price;
                    tattoo.StyleName  = _tattoo.StyleName;
                    tattoo.StyleId    = _tattoo.StyleId;
                    tattoo.AuthorName = authorService.GetAll().FirstOrDefault(x => x.AuthorId == _tattoo.AuthorId).Name;
                    tattoo.AuthorId   = _tattoo.AuthorId;
                    tattoo.Image      = _tattoo.Image != null?ImageConverter.GetBytes(_tattoo.Image) : null;

                    tattooService.Add(tattoo);
                    tattooService.Save();
                    return(RedirectToAction(nameof(List)));
                }
            }
            ViewData["StyleId"]  = new SelectList(styleService.GetAll(), "Id", "Name", _tattoo.StyleId);
            ViewData["AuthorId"] = new SelectList(authorService.GetAll(), "AuthorId", "Name", _tattoo.AuthorId);
            return(View(_tattoo));
        }
예제 #21
0
파일: Form1.cs 프로젝트: uguresref/Personel
        //txtFirstName.Text = param;
        //txtLastName.Text = param;
        //txtAddress.Text = param;
        //txtMail.Text = param;
        //txtPhone.Text = param;
        //dtBirthDate.Text = param;


        private void btnSave_Click(object sender, EventArgs e)
        {
            Employee employee = new Employee();
            
            employee.FirstName = txtFirstName.Text;
            employee.LastName = txtLastName.Text;
            employee.Mail = txtMail.Text;
            employee.Phone = txtPhone.Text;
            employee.BirthDate = dtBirthDate.Value;
            employee.Address = txtAddress.Text;
            //employee.Department = cmbDepartment.Text.ToString();
            //employee.Gender = rdRandom.Text;

            ad = txtFirstName.Text;
            soyad = txtLastName.Text;
            mail = txtMail.Text;
            birth = dtBirthDate.Text;
            tel = txtPhone.Text;
            adres = txtAddress.Text;


            //Department department = new Department();
            //department = cmbDepartment.Text;


            _employeeService.Add(employee);
            Form2 frm = new Form2();
            frm.Show();




        }
    public void SendMyQuestion()
    {
        MyCurrentQuestion = new Question();

        MyCurrentQuestion.question = MyQuestionTextBox.text;

        MyCurrentQuestion.language_id = LanguagesDictionary["russian"];

        StartCoroutine(MyQuestionService.Add(
                           MyCurrentQuestion,
                           delegate(Question question)
        {
            MyCurrentQuestion.id = question.id;

            UIAnimator.SetBool("IsMessageFullScreen", true);
            UIAnimator.SetBool("IsMessageSlide", false);

            MyQuestionTextBox.gameObject.SetActive(false);
            MyQuestionText.gameObject.SetActive(true);
            //!!!UpdateMessagesButton.SetActive(true);
            SendMyQuestionButton.SetActive(false);

            MyQuestionText.text            = TextFromMyQuestionTextBox.text;
            TextFromMyQuestionTextBox.text = "";

            //!!!UpdateMessagesFromServer();

            //!!!AnswersCount = 0;
        }
                           )
                       );
    }
 public ActionResult YeniKayit(UserModel model)
 {
     if (ModelState.IsValid)
     {
         bool passwordcontrol = string.Equals(model.Password, model.PasswordAgain);
         if (!passwordcontrol)
         {
             ViewBag.Message = "Hatalı Şifre";
         }
         bool mailcontrol = string.Equals(model.Mail, model.MailAgain);
         if (!mailcontrol)
         {
             ViewBag.Message = "Hatalı Mail Adresi";
         }
         model.RoleId = (int)AppCore.Business.Enums.RoleEnum.Admin;
         var uy = TempData["FabrikaId"].ToString();
         model.FactoryId = Convert.ToInt32(uy);
         userService.Add(model);
         userService.SaveChanges();
         ViewBag.LoginName = model.Name;
         ViewBag.Message   = "İşlem Başarı ile tamamlandı.Bir sonraki kayıt işlemine geçiliyor. ";
         return(RedirectToAction("YeniKayitSonrası"));
     }
     return(View(model));
 }
예제 #24
0
        public IActionResult AddProblem(ProblemDto problemDto)
        {
            var problem = _mapper.Map <Problem>(problemDto);

            _problemService.Add(problem);
            return(Ok());
        }
예제 #25
0
        public IHttpActionResult AlumnoDto(AlumnoDto alumnoDto)
        {
            HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create("http://localhost:41137/");

            httpReq.AllowAutoRedirect = false;
            HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            AlumnoDto alumnoDtoInserted = null;

            try
            {
                alumnoDtoInserted = alumnoService.Add(alumnoDto);
            }
            catch (VuelingException ex)
            {
                if (httpRes.StatusCode == HttpStatusCode.Moved)
                {
                    // Code for moved resources goes here.
                }
                else
                {
                    // ex.Message;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = alumnoDtoInserted.Id }, alumnoDtoInserted));
        }
        public async Task <IActionResult> InserirEntidade(TEntity entidade, string acaoGet)
        {
            _servico.Add(entidade);
            await _servico.SaveChangesAsync();

            return(CreatedAtAction(acaoGet, new { id = entidade.Id }, entidade));
        }
예제 #27
0
        public IActionResult PostAsync([FromBody] PedidoDto pedidoDto)
        {
            var pedido   = pedidoDto.ToModel();
            var idPedido = _service.Add(pedido);

            return(Ok(idPedido));
        }
예제 #28
0
        public static CRStage GetCRStageByCode(this IService <CRStage> service, int crId, string stageCode, int teamId, string remarks, bool createIfNew)
        {
            var query = new ListQuery <CRStage>();

            query.PageSize    = 1;
            query.CurrentPage = 1;
            query.AddParameter("StageCode", stageCode);
            query.AddParameter("crId", crId.ToString());
            var list = service.GetByQuery(query).Items;

            if (list != null && list.Count > 0)
            {
                return(list.FirstOrDefault());
            }
            if (createIfNew)
            {
                return(service.Add(new CRStage()
                {
                    RCB = new Core.Domian.Settings.User()
                    {
                        Id = 1
                    }, RCT = DateTime.Now, SrNo = 1, RUT = DateTime.Now, Title = stageCode, StageCode = stageCode, CRId = crId, TeamId = teamId, Remarks = remarks
                }));
            }
            return(null);
        }
        private void Add()
        {
            Question question = new Question(txtQuestion.Text, SurveyId);

            _service.Add(question);
            clearData();
        }
예제 #30
0
        private static void Main(string[] args)
        {
            GenerateCampaigns();
            GenerateGames();
            GenerateGamers();
            var gameList     = _gameService.GetAll();
            var randomGame   = gameList.ElementAt(_random.Next(gameList.Count() - 1));
            var gameCampaign = _campaignService.Get(randomGame.CampaignId);
            var gamers       = _gamerService.GetAll();
            var randomGamer  = gamers.ElementAt(_random.Next(gamers.Count() - 1));

            _gameOrderService.Add(new GameOrder
            {
                Id           = Guid.NewGuid(),
                AmountPaid   = randomGame.Price - (randomGame.Price * gameCampaign.Discount),
                Game         = randomGame,
                Gamer        = randomGamer,
                IsDeleted    = false,
                PurchaseDate = DateTime.Now
            }).Wait();

            ListOrders();

            Console.ReadKey();
        }