コード例 #1
0
ファイル: ContactsController.cs プロジェクト: kgrgl/PhoneBook
        public async Task <IActionResult> Create(Contacts contacts)
        {
            if (contacts.ContactType == Contacts.ContactTypes.Location)
            {
                if (!ValidateLocationValues(contacts.ContactText))
                {
                    return(NotFound("Lütfen Geçerli Bir Lokasyon Giriniz!"));
                }
            }
            else if (contacts.ContactType == Contacts.ContactTypes.Mail)
            {
                if (!new EmailAddressAttribute().IsValid(contacts.ContactText))
                {
                    return(NotFound("Lütfen Geçerli Bir Mail Adresi Giriniz!"));
                }
            }
            else if (contacts.ContactType == Contacts.ContactTypes.Phone)
            {
                if (!new PhoneAttribute().IsValid(contacts.ContactText))
                {
                    return(NotFound("Lütfen Geçerli Bir Telefon Numarası Giriniz!"));
                }
            }
            _context.Add(contacts);
            await _context.SaveChangesAsync();

            return(Ok(contacts));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,ConfigrationId,DefectInPhone,IsRepairable,RepairDate")] Repair repair)
        {
            if (ModelState.IsValid)
            {
                _context.Add(repair);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(repair));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("PhoneId,NameOfPhone,Company,Cost,Stock")] Phone phone)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phone);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(phone));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("Id,Model,PhoneId,Storage,RAM")] Configration configration)
        {
            if (ModelState.IsValid)
            {
                _context.Add(configration);
                await _context.SaveChangesAsync();

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