public IHttpActionResult PutIntigrationMaster(int id, IntigrationMaster intigrationMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != intigrationMaster.requestId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult GetRequest(decimal aadharNo, string eUid, string type)
        {
            //Getting id and birth day from aadhar number
            var data = from asd in db.AadharMasters where asd.aadharNo == aadharNo select new { asd.id, asd.dob };
            int id   = 0;

            System.DateTime dob = System.DateTime.Now;
            foreach (var item in data)
            {
                id  = item.id;
                dob = Convert.ToDateTime(item.dob);
            }

            //It can be improved.
            DateTime today = DateTime.Today;
            int      age   = today.Year - dob.Year;

            if (dob > today.AddYears(-age))
            {
                age--;
            }

            IntigrationMaster im = new IntigrationMaster()
            {
                id = id, aadharNo = aadharNo, externalUniqueId = eUid, clientType = type, requestDateTime = DateTime.Now
            };

            db.IntigrationMasters.Add(im);
            db.SaveChanges();
            int newRequestID = im.requestId;

            Random rnd  = new Random();
            int    motp = rnd.Next(1000, 9999);
            int    eotp = rnd.Next(100000, 999999);

            OTPMaster om = new OTPMaster()
            {
                requestId = newRequestID, mOTP = motp, eOTP = eotp
            };

            db.OTPMasters.Add(om);
            db.SaveChanges();

            var     cinfo = from asd in db.ContectMasters where asd.id == id && asd.isPrimary == true select asd;
            decimal pno   = 0;
            string  email = null;

            foreach (var item in cinfo)
            {
                pno   = Convert.ToDecimal(item.phoneNumber);
                email = item.emailId;
            }
            var result = new { requestId = newRequestID, Age = age, phoneNo = pno, emailId = email };

            return(Ok(result));
        }
        public IHttpActionResult GetIntigrationMaster(int id)
        {
            IntigrationMaster intigrationMaster = db.IntigrationMasters.Find(id);

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

            return(Ok(intigrationMaster));
        }
        public IHttpActionResult PostIntigrationMaster(IntigrationMaster intigrationMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.IntigrationMasters.Add(intigrationMaster);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = intigrationMaster.requestId }, intigrationMaster));
        }
        public IHttpActionResult DeleteIntigrationMaster(int id)
        {
            IntigrationMaster intigrationMaster = db.IntigrationMasters.Find(id);

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

            db.IntigrationMasters.Remove(intigrationMaster);
            db.SaveChanges();

            return(Ok(intigrationMaster));
        }