예제 #1
0
        public IHttpActionResult PutLoginCitizen(int id, LoginCitizen loginCitizen)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != loginCitizen.LoginId)
            {
                return(BadRequest());
            }

            db.Entry(loginCitizen).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoginCitizenExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GetLoginCitizen(int id)
        {
            LoginCitizen loginCitizen = db.LoginCitizens.Find(id);

            if (loginCitizen == null)
            {
                return(NotFound());
            }

            return(Ok(loginCitizen));
        }
예제 #3
0
        public IHttpActionResult PostLoginCitizen(LoginCitizen loginCitizen)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.LoginCitizens.Add(loginCitizen);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = loginCitizen.LoginId }, loginCitizen));
        }
예제 #4
0
        public IHttpActionResult DeleteLoginCitizen(int id)
        {
            LoginCitizen loginCitizen = db.LoginCitizens.Find(id);

            if (loginCitizen == null)
            {
                return(NotFound());
            }

            db.LoginCitizens.Remove(loginCitizen);
            db.SaveChanges();

            return(Ok(loginCitizen));
        }
        public ActionResult ConfirmIndex(Citizen s, Address address, string inlineDefaultRadiosExample, int?State, Upload f1)
        {
            var fatherName = db.Citizens.Find(s.citizen_father_id);

            s.citizen_second_name        = fatherName.citizen_first_name;
            s.citizen_third_name         = fatherName.citizen_second_name;
            s.citizen_fourth_name        = fatherName.citizen_third_name;
            s.citizen_second_name_arabic = fatherName.citizen_first_name_arabic;
            s.citizen_third_name_arabic  = fatherName.citizen_second_name_arabic;
            s.citizen_fourth_name_arabic = fatherName.citizen_third_name_arabic;
            s.TransactionDate            = DateTime.Now;
            db.Citizens.Add(s);
            db.SaveChanges();


            if (ModelState.IsValid)
            {
                if (inlineDefaultRadiosExample == "WithF")
                {
                    var data = (
                        from ad in db.AddressCitizens
                        from cit in db.Citizens
                        from addd in db.Addresses.Where(a => a.address_id == ad.CA_AddressId &&
                                                        s.citizen_father_id == ad.CA_CitizenId && a.address_isCurrent == true && s.citizen_father_id == cit.citizen_id
                                                        )
                        select new
                    {
                        addd.address_district_id,
                        addd.address_id,
                        addd.address_isBirthPlace,
                        addd.address_isCurrent,
                        addd.address_isDelete,
                        addd.address_street,
                        addd.address_street_arabic
                    }

                        ).SingleOrDefault();

                    address.address_district_id = data.address_district_id;

                    address.address_isBirthPlace  = data.address_isBirthPlace;
                    address.address_isCurrent     = data.address_isCurrent;
                    address.address_street        = data.address_street;
                    address.address_street_arabic = data.address_street_arabic;
                }

                if (inlineDefaultRadiosExample == "WithM")
                {
                    var data = (
                        from ad in db.AddressCitizens
                        from cit in db.Citizens
                        from addd in db.Addresses.Where(a => a.address_id == ad.CA_AddressId &&
                                                        s.citizen_mother_id == ad.CA_CitizenId && a.address_isCurrent == true && s.citizen_mother_id == cit.citizen_id
                                                        )
                        select new
                    {
                        addd.address_district_id,
                        addd.address_id,
                        addd.address_isBirthPlace,
                        addd.address_isCurrent,
                        addd.address_isDelete,
                        addd.address_street,
                        addd.address_street_arabic
                    }

                        ).SingleOrDefault();

                    address.address_district_id = data.address_district_id;

                    address.address_isBirthPlace  = data.address_isBirthPlace;
                    address.address_isCurrent     = data.address_isCurrent;
                    address.address_street        = data.address_street;
                    address.address_street_arabic = data.address_street_arabic;
                }



                db.Addresses.Add(address);
                db.SaveChanges();


                AddressCitizen c = new AddressCitizen();
                c.CA_AddressId = address.address_id;

                c.CA_CitizenId = s.citizen_id;
                db.AddressCitizens.Add(c);

                db.SaveChanges();

                Document d = new Document();


                var fff = db.Document_Type.Find(f1.document_documentType_id);
                d.document_documentType_id = f1.document_documentType_id;
                string filename     = s.citizen_national_id + "_" + fff.document_type_name + "_" + f1.file.FileName + Path.GetExtension(f1.file.FileName);
                string filePath     = Server.MapPath("~/DocumentDataURL/" + filename);
                string filePathName = Path.Combine(filename, filePath);
                f1.file.SaveAs(filePathName);

                //==================================================

                d.document_citizen_id = s.citizen_id;

                //==========================
                d.document_data = filePathName;

                d.document_name        = filename;
                d.document_date_upload = DateTime.Now.ToString();

                //===============================
                //  int l = filename.Length;
                // string length = filename.Substring(l - 3, 3);
                d.document_extensions = Path.GetExtension(f1.file.FileName);

                //=========================================
                // d.document_id = 0;
                db.Documents.Add(d);

                db.SaveChanges();
                LoginCitizen log = new LoginCitizen();
                log.Login_CitizenId  = s.citizen_id;
                log.Login_CitizenNId = s.citizen_national_id;
                var pp = Encrypt.enc(s.citizen_national_id);
                log.Login_Password = pp;
                log.Login_QRcode   = pp;
                db.LoginCitizens.Add(log);
                db.SaveChanges();


                return(RedirectToAction("Index", "home"));
            }
            return(View());
        }
        public ActionResult ConfirmIndex()
        {
            string www      = Session["Nai"].ToString();
            var    validate = db.Citizens.Where(a => a.citizen_national_id == www).SingleOrDefault();

            if (validate != null)
            {
                Session["success"] = Languages.Language.CitizenAlreadExist;
                return(RedirectToAction("Index", "home"));
            }



            Citizen c = new Citizen();

            //-----------------citizen infooo----------------------------
            if (Session["second"] != null)
            {
                c.citizen_second_name = Session["second"].ToString();
            }
            //third
            if (Session["third"] != null)
            {
                c.citizen_third_name = Session["third"].ToString();
            }
            //fourth
            if (Session["fourth"] != null)
            {
                c.citizen_fourth_name = Session["fourth"].ToString();
            }

            if (Session["secondArabic"] != null)
            {
                c.citizen_second_name_arabic = Session["secondArabic"].ToString();
            }


            if (Session["thirdArabic"] != null)
            {
                c.citizen_third_name_arabic = Session["thirdArabic"].ToString();
            }

            if (Session["fourthArabic"] != null)
            {
                c.citizen_fourth_name_arabic = Session["fourthArabic"].ToString();
            }


            if (Session["FirstName"] != null)
            {
                c.citizen_first_name = Session["FirstName"].ToString();
            }

            if (Session["FirstNameArabic"] != null)
            {
                c.citizen_first_name_arabic = Session["FirstNameArabic"].ToString();
            }

            if (Session["FId"] != null)
            {
                c.citizen_father_id = Convert.ToInt32(Session["FId"]);
            }

            if (Session["MId"] != null)
            {
                c.citizen_mother_id = Convert.ToInt32(Session["MId"]);
            }



            c.citizen_birthDate = Convert.ToDateTime(Session["BirthDate"]);


            c.citizen_relegion = Session["relegion"].ToString();
            if (Session["gender"] != null)

            {
                if (Session["gender"].ToString().Equals("Male") || Session["gender"].ToString().Equals("ذكر"))

                {
                    Session["gender"] = "Male";
                }
                else if (Session["gender"].ToString().Equals("Female") || Session["gender"].ToString().Equals("انثى"))

                {
                    Session["gender"] = "Female";
                }
            }


            if (Session["relegion"] != null)
            {
                if (Session["relegion"].ToString() == "Muslim" || Session["relegion"].ToString() == "مسلم")
                {
                    Session["relegion"] = "Muslim";
                }
                else if (Session["relegion"].ToString() == "Cristian" || Session["relegion"].ToString() == "مسيحي")
                {
                    Session["relegion"] = "Cristian";
                }
                else if (Session["relegion"].ToString() == "Jewish" || Session["relegion"].ToString() == "يهودي")
                {
                    Session["relegion"] = "Jewish";
                }
            }

            c.citizen_relegion          = Session["relegion"].ToString();
            c.citizen_gender            = Session["gender"].ToString();
            c.citizen_birthPlace        = Session["BirthPlace"].ToString();
            c.citizen_birthPlace_arabic = Session["BirthPlaceArabic"].ToString();
            c.citizen_national_id       = Session["Nai"].ToString();

            db.Citizens.Add(c);
            db.SaveChanges();
            //----------------------Addresses------------------------------
            string  aa = Session["asas"].ToString();
            Address ad = new Address();

            if (aa == "WithF")
            {
                ad.address_district_id   = Convert.ToInt32(Session["AddressDistrictIdFF"]);
                ad.address_isBirthPlace  = Convert.ToBoolean(Session["AddressIsBirthPlaceFF"]);
                ad.address_isCurrent     = Convert.ToBoolean(Session["AddressIsCurrentFF"]);
                ad.address_street        = Session["AddresStreetFF"].ToString();
                ad.address_street_arabic = Session["AddresStreetFFArabic"].ToString();
                db.Addresses.Add(ad);
                db.SaveChanges();
            }
            if (aa == "WithM")
            {
                ad.address_district_id   = Convert.ToInt32(Session["AddressDistrictIdMM"]);
                ad.address_isBirthPlace  = Convert.ToBoolean(Session["AddressIsBirthPlaceMM"]);
                ad.address_isCurrent     = Convert.ToBoolean(Session["AddressIsCurrentMM"]);
                ad.address_street_arabic = Session["AddresStreetMMArabic"].ToString();
                db.Addresses.Add(ad);
                db.SaveChanges();
            }
            if (aa == "other")
            {
                ad.address_street        = Session["AddresStreetOO"].ToString();
                ad.address_street_arabic = Session["AddresStreetOOArabic"].ToString();
                ad.address_isCurrent     = Convert.ToBoolean(Session["IsCurrenOO"]);
                ad.address_district_id   = Convert.ToInt32(Session["disId"]);
                db.Addresses.Add(ad);
                db.SaveChanges();
            }
            //-------------------Address citizen m To m ----------------------
            AddressCitizen cc = new AddressCitizen();

            cc.CA_AddressId = ad.address_id;
            cc.CA_CitizenId = c.citizen_id;
            db.AddressCitizens.Add(cc);
            db.SaveChanges();


            //----------------------------Documents--------------------------
            Document doc = new Document();

            doc.document_name            = Session["filename"].ToString();
            doc.document_extensions      = Session["extension"].ToString();
            doc.document_documentType_id = Convert.ToInt32(Session["documentTypeName"]);
            doc.document_data            = Session["docData"].ToString();
            doc.document_citizen_id      = c.citizen_id;
            doc.document_date_upload     = Session["uploadDate"].ToString();
            db.Documents.Add(doc);
            db.SaveChanges();

            //---------------------- Login Citizen table ---------------------
            LoginCitizen log = new LoginCitizen();

            // qr code consist of datetime now , datetime seconds , datetime milliseconds , first name and national id
            log.Login_CitizenNId = c.citizen_national_id;
            string pass = Encrypt.enc(c.citizen_national_id);

            log.Login_Password  = pass;
            log.Login_PinNumber = "1234";
            log.Login_CitizenId = c.citizen_id;
            string qr = Encrypt.enc(DateTime.Now.ToString() + "_" + DateTime.Now.Second + "_" + DateTime.Now.Millisecond + "_" + c.citizen_first_name + "_" + c.citizen_national_id);

            log.Login_QRcode = qr;
            db.LoginCitizens.Add(log);
            db.SaveChanges();

            //--------------------------------------- Live Status -------------------------
            Live_Status live = new Live_Status();

            live.live_satus_type_id = 1;
            live.citizen_citizen_id = c.citizen_id;
            db.Live_Status.Add(live);
            db.SaveChanges();


            Session["success"] = Languages.Language.CitizenAddedSuccessfully;
            return(RedirectToAction("Index", "home"));
        }