コード例 #1
0
ファイル: MenuController.cs プロジェクト: swajrizwan/PakVisa
        public async Task <IActionResult> AddUpdateCountry(string GetCountry)
        {
            if (ModelState.IsValid)
            {
                var country = new Country()
                {
                    Description = GetCountry
                };
                await _repository.Add(country);

                await _repository.Save();

                ModelState.AddModelError("", "Country Added Successfully");
                return(Json(true));
            }
            else
            {
                return(Json(false));
            }
        }
コード例 #2
0
        public async Task <IActionResult> AddCountry(string country)
        {
            if (country != null)
            {
                var newCountry = new Country()
                {
                    Description = country
                };

                await _repository.Add(newCountry);

                if (await _repository.Save())
                {
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
            return(Json(false));
        }
コード例 #3
0
        public async Task <IActionResult> Register(FranchiseViewModel model)
        {
            if (ModelState.IsValid)
            {
                var signUp = new Userlogin()
                {
                    Name          = model.Name,
                    Username      = model.Username,
                    Password      = model.Password,
                    IsUserClient  = true,
                    IsUserAdmin   = false,
                    IsUserVisitor = false
                };
                await _repository.Add(signUp);

                await _repository.Save();

                var user = _repository.ClientSignIn(signUp.Username, signUp.Password);
                if (user != null)
                {
                    var franchise = new Franchise()
                    {
                        Address     = model.Address,
                        Date        = DateTime.Now,
                        Fax         = model.Fax,
                        IsApproved  = model.IsApproved,
                        IsRestrict  = model.IsRestrict,
                        Landline    = model.Landline,
                        Name        = model.FranchiseName,
                        Phone       = model.Phone,
                        Phone2      = model.Phone2,
                        UserloginId = user.UserloginId,
                    };
                    var stream = new MemoryStream();
                    using (stream)
                    {
                        await model.Agreement.CopyToAsync(stream);

                        franchise.Agreement = stream.ToArray();
                        stream.Flush();
                        await model.CNICPassport.CopyToAsync(stream);

                        franchise.CNICPassport = stream.ToArray();
                        stream.Flush();
                        await model.DTSLicense.CopyToAsync(stream);

                        franchise.DTSLicense = stream.ToArray();
                        stream.Flush();
                        await model.IATALicense.CopyToAsync(stream);

                        franchise.IATALicense = stream.ToArray();
                        stream.Flush();
                        await model.Logo.CopyToAsync(stream);

                        franchise.Logo = stream.ToArray();
                        stream.Flush();
                        await model.NTNCertificate.CopyToAsync(stream);

                        franchise.NTNCertificate = stream.ToArray();
                    }
                    await _repository.Add(franchise);
                }
                await _repository.Save();
            }
            return(View());
        }