//Mobile Regis public DL_MobileRegistrationReturn MobileRegistration(DL_MobileRegistration mobileReg) { this.SpName = DL_StoreProcedure.SP_InsertRegisterMobile; //Sp Name mobileRegReturn = new DL_MobileRegistrationReturn(); _IsSuccess = true; try { SqlParameter[] param = new SqlParameter[4]; param[0] = new SqlParameter("@Name", mobileReg.Name); param[1] = new SqlParameter("@UserType", mobileReg.Key);//change in future param[2] = new SqlParameter("@MobileNo", mobileReg.Mobile); param[3] = new SqlParameter("@UserId", mobileReg.UserId); ds = db.GetDataSet(this.SpName, param); if (ds != null && ds.Tables.Count > 0) { //ds.Tables var Json = JsonConvert.SerializeObject(ds.Tables[0]).TrimEnd(']').TrimStart('['); mobileRegReturn = JsonConvert.DeserializeObject <DL_MobileRegistrationReturn>(Json); string message = "Dear " + mobileReg.Name + " , Mobile No. " + mobileReg.Mobile + " has been successfully registered. CREBIT Customer Experience Team."; BL_SMS.SendSMS(mobileReg.Mobile, message); } } catch (Exception ex) { Exception err = ex; _IsSuccess = false; } return(mobileRegReturn); }
public HttpResponseMessage MobileRegistration(HttpRequestMessage req, DL_MobileRegistration mobileReg) { Logger.WriteLog(LogLevelL4N.INFO, "Got MobileRegistration req. "); User user = new User() { Password = mobileReg.Key, UserId = mobileReg.UserId }; Validation.UserCheck(user); if (Validation._IsSuccess) { try { if (mobileReg != null && !string.IsNullOrEmpty(mobileReg.Name) && !string.IsNullOrEmpty(mobileReg.UserId) && !string.IsNullOrEmpty(mobileReg.Mobile) && !string.IsNullOrEmpty(mobileReg.Key)) { // Logger.WriteLog(LogLevelL4N.INFO, "Process request | Mobile :" + mobileReg.Mobile + " UserId : " + mobileReg.UserId + " UserType : " + mobileReg.Key); DL_MobileRegistrationReturn mobileRegReturn = dash.MobileRegistration(mobileReg); if (dash._IsSuccess) { return(req.CreateResponse <DL_MobileRegistrationReturn>(HttpStatusCode.OK, mobileRegReturn)); } else { return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, "ServerError")); } } Logger.WriteLog(LogLevelL4N.FATAL, "Bad Request"); return(req.CreateResponse(HttpStatusCode.BadRequest, "Bad Request")); } catch (Exception ex) { Logger.WriteLog(LogLevelL4N.ERROR, "Inside the MobileRegistration api | Error : " + ex.Message); } } Logger.WriteLog(LogLevelL4N.FATAL, "Unauthorized Request"); return(req.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized")); }